Avatar of Jim Youmans
Jim Youmans
Flag for United States of America

asked on 

DB2 Insert into a identity column

DB2 10.5 on Windows

I am trying to delete a lot of data from a table.  I created a duplicate of the table with a different name and am trying to move the last years worth of data to it, then truncate the original data and then move the saved data back to the original.

There is an ID column that is set up like this.

ID	INTEGER	NOT NULL	GENERATED ALWAYS
AS IDENTITY (START WITH 1, INCREMENT BY 1, CACHE 20,
NO MINVALUE, NO MAXVALUE, NO CYCLE, NO ORDER)

Open in new window


When I run this to move the data back

INSERT INTO ORIGINAL_TABLE OVERRIDING SYSTEM VALUE (SELECT * FROM DUPLICATE_TABLE WHERE  DATE(LASTTIME) >= '01-01-2017')

Open in new window


I get this

ERROR [42601] [IBM][DB2/NT64] SQL0104N  An unexpected token "OVERRIDING SYSTEM VALUE" was found following "ORIGINAL_TABLE".  Expected tokens may include:  "<space>".

Open in new window


Everything I have read says the OVERRIDING SYSTEM VALUE should work but it does not.  I am sure it is a simple issue but I have wasted 1/2 a day on trying to figure it out.  Any help would be greatly appreciated!!

Jim
Windows OSDB2

Avatar of undefined
Last Comment
Jim Youmans

8/22/2022 - Mon