pvsbandi
asked on
Auto Increment in Insert into Select
Hi,
I'm on DB2 UDB 8.2.
I have a table TB_INS_JOB(A INT, B VARCHAR(20),C VARCHAR(10));
I'm doing the following:
INSERT INTO TB_INS_JOB(B,C)
SELECT B,C FROM TB_CP_JOB;
When i insert the values into TB_INS_JOB, i want the values in the column to Auto Increment, for each row inserted.
How can i do it? Please advise.
I'm on DB2 UDB 8.2.
I have a table TB_INS_JOB(A INT, B VARCHAR(20),C VARCHAR(10));
I'm doing the following:
INSERT INTO TB_INS_JOB(B,C)
SELECT B,C FROM TB_CP_JOB;
When i insert the values into TB_INS_JOB, i want the values in the column to Auto Increment, for each row inserted.
How can i do it? Please advise.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi simpsol,
Actually, the DDL for an auto increment column is different for SQL Server, MySQL, DB2, and Oracle. Just substituting the keyword 'IDENTITY' with 'AUTOINCREMENT' isn't enough.
Kent
Actually, the DDL for an auto increment column is different for SQL Server, MySQL, DB2, and Oracle. Just substituting the keyword 'IDENTITY' with 'AUTOINCREMENT' isn't enough.
Kent
ASKER
Excellent!! Thanks!
Micorosft Access : AutoNumber
Microsoft SQL : Identity
Oracle: Sequence
DB2 might have something similari.