Alter Column to Auto Increment

2,277 views
Skip to first unread message

mauriziopz

unread,
Aug 28, 2009, 3:22:19 PM8/28/09
to H2 Database
Hi I'm new here,
I'm working on a simple database for personal use. I've created all
the tables through openoffice base connected to the h2 db.
Don't know why but, while creating the tables, I couldn't set the IDs
to be autoincremented... Now I'm trying to alter them to set the IDs
to autoincrement but I couldn't get it to work...
I'm using this statement
ALTER TABLE "TipoCibo" ALTER COLUMN "ID" INT AUTO_INCREMENT

and get this error

Attempt to define a second primary key; SQL statement:
ALTER TABLE "TipoCibo" ALTER COLUMN "ID" INT AUTO_INCREMENT
[90017-116] 90017/90017 (Aiuto)


btw
it looks like it is not possible to alter a column trought openoffce,
you can only add new ones, you know why?

Thanks

Thomas Mueller

unread,
Sep 2, 2009, 12:19:37 AM9/2/09
to h2-da...@googlegroups.com
Hi,

This is a bug. The problem is, originally creating a table with a
column of type AUTO_INCREMENT automatically created a primary key for
this column. It doesn't do that any longer, at least not in the CREATE
TABLE statement. However it still tries to do that for ALTER TABLE
ALTER COLUMN. I will fix this for the next release (this weekend).

Thanks for your help!

Regards,
Thomas

mauriziopz

unread,
Sep 2, 2009, 1:17:30 PM9/2/09
to H2 Database
Thanks!

On 2 Set, 06:19, Thomas Mueller <thomas.tom.muel...@gmail.com> wrote:
> Hi,
>
> This is a bug. The problem is, originally creating a table with a
> column of type AUTO_INCREMENT automatically created a primary key for
> this column. It doesn't do that any longer, at least not in the CREATE
> TABLE statement. However it still tries to do that for ALTER TABLE
> ALTER COLUMN. I will fix this for the next release (this weekend).
>
> Thanks for your help!
>
> Regards,
> Thomas
>
Reply all
Reply to author
Forward
0 new messages