You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Jim Newsham <jn...@referentia.com> on 2008/09/30 03:39:11 UTC

change identity type

 

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?

 

Thanks,

 

Jim


Re: change identity type

Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Jim Newsham <jn...@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