SQL语句中的意外令牌

时间:2018-10-08 14:30:56

标签: sql libreoffice unexpected-token

我正在LibreOfficeBase中使用odb文件,并尝试一次插入一堆行。

我正在使用以下代码:

INSERT INTO RELATIONSHIP_BTWN_PEOPLE ("RelationID", "SubjectPersonID", "RelationType", "ObjectPersonID")
VALUES (11501, 9163, 'Parent Of',9165),
VALUES (11502, 9164, 'Parent Of',9165),
VALUES (11503, 9165, 'Child Of',9163),
VALUES (11504, 9165, 'Child Of',9164);

我收到以下错误:

  

意外的标记,在语句[,]

但是当我删除逗号时,会出现错误

  

意外的VALUES语句

我知道代码正在工作,因为它确实在[,]

之前输入了第一行

对于这个问题,我看到的两个答案是:

  1. 它是由格式化的文本(即以Microsoft Word之类的文字)导致的-但是我是直接在Command SQL框中写的
  2. 这是由于使用了保留的关键字所致-但我看不出此代码中可以保留的内容。

2 个答案:

答案 0 :(得分:1)

您必须省略第二名,并且超越values。试试:

  INSERT INTO RELATIONSHIP_BTWN_PEOPLE ("RelationID","SubjectPersonID","RelationType", "ObjectPersonID")
    VALUES (11501, 9163, 'Parent Of',9165),
    (11502, 9164, 'Parent Of',9165),
    (11503, 9165, 'Child Of',9163),
    (11504, 9165, 'Child Of',9164);

答案 1 :(得分:0)

您需要4条插入语句:

INSERT INTO RELATIONSHIP_BTWN_PEOPLE ("RelationID","SubjectPersonID","RelationType", "ObjectPersonID") VALUES (11501, 9163, 'Parent Of',9165);
INSERT INTO RELATIONSHIP_BTWN_PEOPLE ("RelationID","SubjectPersonID","RelationType", "ObjectPersonID")    VALUES (11502, 9164, 'Parent Of',9165);
INSERT INTO RELATIONSHIP_BTWN_PEOPLE ("RelationID","SubjectPersonID","RelationType", "ObjectPersonID")    VALUES (11503, 9165, 'Child Of',9163);
INSERT INTO RELATIONSHIP_BTWN_PEOPLE ("RelationID","SubjectPersonID","RelationType", "ObjectPersonID")    VALUES (11504, 9165, 'Child Of',9164);