db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Narayanan <V.Naraya...@Sun.COM>
Subject Re: moving columns between tables
Date Wed, 20 Feb 2008 10:22:38 GMT
Amir Michail wrote:
> On Feb 19, 2008 1:25 PM, Bryan Pendleton <bpendleton@amberpoint.com> wrote:
>   
>>> Is there a way to easily move a column from one table to another (as
>>> easy as a rename say)?
>>>       
>> alter table newtable add column newcolumn whatever-data-type;
>> update newtable set newcolumn = (value that the newcolumn should have);
>> alter table oldtable drop column oldcolumn;
>>
>> You'll also have to do some work to drop any constraints on
>> the old column from the old table, then add those constraints
>> to the new column in the new table once it's populated.
>>     
>
> Can't all this be done automatically with a new move command?
>
> Amir
>   
If by "automatically" you mean one command to do everything,
you could consider whether writing a stored procedure that does
all that you want and calling it would be good enough.

You can read more about stored procedures in derby here
http://wiki.apache.org/db-derby/DerbySQLroutines
>   
>> thanks,
>>
>> bryan
>>
>>
>>
>>     


Mime
View raw message