Skip to content
Advertisement

DB2 add auto increment column to an existing table

I have a table with following schema in my DB2 database.

I need to add a new column ID of Type integer not null auto increment, and make it the primary key. How can I do that without deleting the table?

Advertisement

Answer

I could do this successfully using following set of queries.

And then add primary key using alter table.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement