台账建立和sqlite数据库的数据导入和导入问题
principle
platform command starts with ".";
whiel sql command doesn't starts with ".", but ends with ";"
===============================================
错误现象:
=============================================
.import device_test.txt device;
Error: no such table: device;
sqlite>
原因 device后面不该有分号;
解决:命令改为 .import device_test.txt device
注意,以“.”开头
================================
sqlite> .import test.txt device
test.txt:1: expected 5 columns but found 1 - filling the rest with NULL
test.txt:2: expected 5 columns but found 1 - filling the rest with NULL
test.txt:3: expected 5 columns but found 1 - filling the rest with NULL
cause: 没有设置seperator ","
solution: input : .separator ","
===================================
常用命令
delete from TableName; //清空数据 update sqlite_sequence SET seq = 0 where name ='TableName';//自增长ID为0
select count(*) from device;
cd D:\sqlite_files\sqlite-tools-win32-x86-3230100
运行 sqlite3 device.db
出现sqlite>
退出命令 .quit
D:\sqlite_files\sqlite-tools-win32-x86-3230100>sqlite3.exe device.db
SQLite version 3.23.1 2018-04-10 17:39:29
Enter ".help" for usage hints.
sqlite> .tables ++++++++++++显示所有表格的表名
device
sqlite>
查看表结构
sqlite> .schema
CREATE TABLE device
(
id text,
device_no text,
device_name text,
owner text,
register_date text
);
sqlite>
sql3> select * from device;
我自己总结的sqlite 的命令行命令
导入文本数据文件时,设置分隔符为","
sql>.separator ","
sql>.import devices_20181206.txt device
注意import 前面有一个".",而且不要以;结尾
txt文件必须另存为utf8格式
sqlite数据库安装在d:\sqlite_files
运行sqlite3
查看数据表,命令,.tables
数据库文件 d:\sqlite_files\device.db
create table device
(
id text,
device_no text,
device_name text,
owner text,
register_date text
)
建立目录D:\android_projects\qrscan\app\src\main\assets
把数据库文件d:\sqlite_files\device.db 拷贝到 D:\android_projects\qrscan\app\src\main\assets
然后在as中,即android studio中出现该文件图标,右键点击,选择sql文件即可
++++++++++++++++++++++++++++++++++++++++++
问题
导入数据,import
出现提示
device_20181214.txt:683: expected 5 columns but found 1 - filling the rest with
NULL
device_20181214.txt:684: expected 5 columns but found 1 - filling the rest with
NULL
device_20181214.txt:685: expected 5 columns but found 1 - filling the rest with
NULL
device_20181214.txt:686: expected 5 columns but found 1 - filling the rest with
NULL
解决,不理它。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)