" SQLite错误",":语法错误"

时间:2018-04-27 07:38:39

标签: sqlite

我正在使用 sqlite3 并尝试将数据放入我的数据库。

INSERT INTO Structure VALUES
('521D5E7ABC165','1','DECODE','T','4','Y','Y'),
('521D5E7ABC165','2','DEDESC','T','40','N','Y'), 
('521D5E7ABC165','3','DDZMD8','T','10','N','Y'), 
('521D5E7ABC165','4','DDZMTM','T','8','N','Y'), 
('521D5E7ABC165','5','DDZMID','T','10','N','Y'), 
('521D5E7ABC165','6','DDZMTL','T','10','N','Y'), 
('521D5E7ABC165','7','DDZMBR','T','5','N','Y'),
('521D5E7ABC165','8','DDZND8','T','10','N','Y'), 
('521D5E7ABC165','9','DDZNTM','T','8','N','Y'), 
('521D5E7ABC165','10','DDZNID','T','10','N','Y'), 
('521D5E7ABC165','11','DDZNTL','T','10','N','Y'), 
('521D5E7ABC165','12','DDZNBR','T','5','N','Y')

我尝试在 DBBrowser 中执行 SQLLITE 的命令,但是当我尝试通过System.Data.SQLite.dll - ExecuteNonQuery执行时,它会返回错误:

  

" SQLite错误",":语法错误"

有人可以帮忙吗?

这是表结构

CREATE TABLE `Structure` (
    `HeaderID`  TEXT,
    `SeqNo` INTEGER,
    `FieldName` TEXT,
    `FieldType` TEXT,
    `FieldLength`   TEXT,
    `IsKey` TEXT,
    `IncludeRecord` TEXT,
    PRIMARY KEY(`HeaderID`,`SeqNo`)
);

sqlite3 版本为:3.15.2

1 个答案:

答案 0 :(得分:0)

使用直接从您的问题中复制的SQL(加上终止;)为我工作。

% sqlite3 so.sqlite3 
SQLite version 3.11.0 2016-02-15 17:29:24
Enter ".help" for usage hints.
sqlite> CREATE TABLE `Structure` (
   ...>     `HeaderID`  TEXT,
   ...>     `SeqNo` INTEGER,
   ...>     `FieldName` TEXT,
   ...>     `FieldType` TEXT,
   ...>     `FieldLength`   TEXT,
   ...>     `IsKey` TEXT,
   ...>     `IncludeRecord` TEXT,
   ...>     PRIMARY KEY(`HeaderID`,`SeqNo`)
   ...> );
sqlite> INSERT INTO Structure VALUES
   ...> ('521D5E7ABC165','1','DECODE','T','4','Y','Y'),
   ...> ('521D5E7ABC165','2','DEDESC','T','40','N','Y'), 
   ...> ('521D5E7ABC165','3','DDZMD8','T','10','N','Y'), 
   ...> ('521D5E7ABC165','4','DDZMTM','T','8','N','Y'), 
   ...> ('521D5E7ABC165','5','DDZMID','T','10','N','Y'), 
   ...> ('521D5E7ABC165','6','DDZMTL','T','10','N','Y'), 
   ...> ('521D5E7ABC165','7','DDZMBR','T','5','N','Y'),
   ...> ('521D5E7ABC165','8','DDZND8','T','10','N','Y'), 
   ...> ('521D5E7ABC165','9','DDZNTM','T','8','N','Y'), 
   ...> ('521D5E7ABC165','10','DDZNID','T','10','N','Y'), 
   ...> ('521D5E7ABC165','11','DDZNTL','T','10','N','Y'), 
   ...> ('521D5E7ABC165','12','DDZNBR','T','5','N','Y');
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE `Structure` (
    `HeaderID`  TEXT,
    `SeqNo` INTEGER,
    `FieldName` TEXT,
    `FieldType` TEXT,
    `FieldLength`   TEXT,
    `IsKey` TEXT,
    `IncludeRecord` TEXT,
    PRIMARY KEY(`HeaderID`,`SeqNo`)
);
INSERT INTO "Structure" VALUES('521D5E7ABC165',1,'DECODE','T','4','Y','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',2,'DEDESC','T','40','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',3,'DDZMD8','T','10','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',4,'DDZMTM','T','8','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',5,'DDZMID','T','10','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',6,'DDZMTL','T','10','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',7,'DDZMBR','T','5','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',8,'DDZND8','T','10','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',9,'DDZNTM','T','8','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',10,'DDZNID','T','10','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',11,'DDZNTL','T','10','N','Y');
INSERT INTO "Structure" VALUES('521D5E7ABC165',12,'DDZNBR','T','5','N','Y');
COMMIT;