.import不支持重塑输入(设置分隔符除外)。您需要将CSV文件导入到临时表中,然后将其插入到真实表中。这是一个示例会话:
$ cat a.csv 1,23,45,6$ sqlite3 a.dbSQLite version 3.6.23.1Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite> create table foo(id integer primary key,x,y);sqlite> create temp table footmp(x,y);sqlite> .separator ,sqlite> .import a.csv footmpsqlite> select * from footmp;1,23,45,6sqlite> insert into foo(x,y) select * from footmp; sqlite> select * from foo; 1,1,22,3,43,5,6sqlite> drop table footmp;
您会看到ID已递增。这是因为类型为
INTEGER PRIMARY KEY的列被视为内部ROWID的别名-内部ROWID始终是唯一的,升序的数字。



