# Database Discussions > IBM DB2 >  Alter Table

## Najjar

Hi all,
I am really new to DB2  :Smilie: 
and I need to know if it is possible to alter a field in a table to be auto increment.
The table already have data in it.
Thank you in advance.

----------


## Najjar

Never mind, it is not possible.
I will have to drop the table and recreate it and of course lose all the data.

Thanks...  :Smilie:

----------


## Rawhide

Create a temporary table to hold the data, drop and recreate the table with an autoincrement field, and then populate the data from the temporary table.

----------


## Najjar

The problem is that the table already 
has values; if I recreate the table and
populate the data in it again I will have new ids; 
sorry I did not mention that the ids in the table are being 
used as FK in another table.

I appreciate your help

----------


## Rawhide

I don't know what the command is for DB2, but there should be a command to allow you to temporarily insert specified values into the field. You will need to drop the foreign key constraint on the other table and then recreate it at the end.

----------


## Najjar

In DB2; If you want to drop a field or even rename it you will have to drop the TABLE and recreate it!!! (strange)
At least this is what I found after searching and asking around;
(I hope that you have a better solution).

We took care of the problem using ASP code because the original tables are in MSSQL 2000 and we need to move them to DB2. (I do not like this idea but it works).

----------

