3

您好我尝试将脚本中的数据插入到具有标识列的 DB2 表中。我使用以下语法阅读:

INSERT INTO SOME_TABLE OVERRIDING SYSTEM VALUE ...

会工作,但它不会。这是确切的查询:

INSERT INTO SCHEMA.MYTABLE OVERRIDING SYSTEM VALUE (
     IDENTITY_COLUMN
    ,SOMEVALUE
    ,CREATEDTIME
    ,UPDATEDTIME
) VALUES (
     2
    ,'656566'
    ,'2012-07-12 16:25:34'
    ,NULL
);

我收到以下错误:

SQL0104N  An unexpected token "VALUE" was found following "DE OVERRIDING 
SYSTEM".  Expected tokens may include:  "<space>".  SQLSTATE=42601

谢谢!

4

1 回答 1

0

如果您使用 Db2 for i,从句法上看,子句位于列列表之后,请参阅文档以及 SQL 标准规范ISO/IEC 9075-2:2016(E) 14.11 <insert statement>。所以,写:

INSERT INTO SCHEMA.MYTABLE (
     IDENTITY_COLUMN
    ,SOMEVALUE
    ,CREATEDTIME
    ,UPDATEDTIME
) 
OVERRIDING SYSTEM VALUE -- Put it here
VALUES (
     2
    ,'656566'
    ,'2012-07-12 16:25:34'
    ,NULL
);
于 2021-12-03T09:27:12.470 回答