我有查询创建的表
CREATE TABLE [ConsignmentBody] ([ConsignmentBodyID] INTEGER PRIMARY KEY AUTOINCREMENT,
[OID] VARCHAR(64),
[Body] CLOB);
CREATE UNIQUE INDEX [ConsignmentBody_OID] ON [ConsignmentBody] ([OID] ASC);
我需要在同一个表中处理具有唯一ID的数据。
我试过了:
insert into ConsignmentBody(ConsignmentBodyID, body.[OID],body.[Body])
select (MAX(body.[ConsignmentBodyID])+1), body.[OID], body.[Body]
from [ConsignmentBody] body
抛出"。"语法错误
插入ConsignmentBody(null,body。[OID],body。[Body]) 选择body。[ConsignmentBodyID],body。[OID],body。[Body] 来自[ConsignmentBody]正文
抛出" null"语法错误
如何解决?
答案 0 :(得分:2)
您在ConsignmentBodyID
上设置了自动增量。你为什么要手动设置值?只需插入没有主键的记录,就应该自动设置
insert into ConsignmentBody(OID, Body)
select OID, Body
from ConsignmentBody