db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: change identity type
Date Tue, 30 Sep 2008 08:17:01 GMT
Jim Newsham <jnewsham@referentia.com> writes:

> I want to change a column from “generated always as identity” to “generated by
> default as identity”.  Do I have to remove/read the column, or is there an
> easier way to do it?

I don't know of any easier way. Unfortunately, Derby currently doesn't
support adding identity columns with ALTER TABLE .. ADD COLUMN (logged
as https://issues.apache.org/jira/browse/DERBY-3888), so I think you
have to create a new table. Something like

1. CREATE TABLE new_table (... same schema as old_table, but replace
"generated always" with "generate by default" ...)

2. INSERT INTO new_table SELECT * FROM old_table

3. DROP TABLE old_table

4. RENAME TABLE new_table TO old_table

Hope this helps,

Knut Anders

View raw message