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_filessqlite-tools-win32-x86-3230100
运行 sqlite3 device.db
出现sqlite>
退出命令 .quit
D:sqlite_filessqlite-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_filesdevice.db
create table device
(
id text,
device_no text,
device_name text,
owner text,
register_date text
)
建立目录D:android_projectsqrscanappsrcmainassets
把数据库文件d:sqlite_filesdevice.db 拷贝到 D:android_projectsqrscanappsrcmainassets
然后在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
解决,不理它。