我试图让我的数据文件(其中有十几个)到sqlite中的表.每个文件都有一个标题,我将在接下来的一年中收到他们几次,所以我想:
原文链接:https://www.f2er.com/sqlite/197583.html>避免编辑每个文件,当我收到它们时删除标题;
>避免掉回shell脚本或Python来执行此操作.
我定义我的表并导入数据…
> .separator "\t" > .headers on > CREATE TABLE clinical( patid VARCHAR(20),eventdate CHAR(10),sysdate CHAR(10),constype INT,consid INT,medcode INT,staffid VARCHAR(20),textid INT,episode INT,enttype INT,adid INT); > .import "Sample_Clinical001.txt" clinical > SELECT * FROM clinical LIMIT 10; patid eventdate sysdate constype consid medcode staffid textid episode enttype adid patid eventdate sysdate constype consid medcode staffid textid episode enttype adid 471001 30/01/1997 09/03/1997 4 68093 180 0 0 0 20 11484 471001 30/01/1997 09/03/1997 2 68093 60 0 0 0 4 11485
我的第一个想法是删除违规行,但是没有按预期的方式工作,而是删除整个表…
> DELETE FROM clinical WHERE patid = "patid"; > SELECT * FROM clinical LIMIT 3; >
我是否得到测试平等错误的语法?我不确定; the docs似乎不区分两者.我以为我会再试一次
> .import "Sample_Clinical001.txt" clinical > SELECT * FROM clinical LIMIT 3; patid eventdate sysdate constype consid medcode staffid textid episode enttype adid patid eventdate sysdate constype consid medcode staffid textid episode enttype adid 471001 30/01/1997 09/03/1997 4 68093 180 0 0 0 20 11484 471001 30/01/1997 09/03/1997 2 68093 60 0 0 0 4 11485 > DELETE FROM clinical WHERE patid == "patid"; > SELECT * FROM clinical LIMIT 3; >
我甚至在这里正确的轨道上,还是我做一些愚蠢的事情?