db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dag.Wan...@Sun.COM (Dag H. Wanvik)
Subject Re: How to insert new column in front of exsiting column?
Date Thu, 14 May 2009 03:02:22 GMT
Daniel Noll <daniel@nuix.com> writes:

> Bryan Pendleton wrote:
>>> I saw the "alter table" only insert the column to the end of the table,
>> Yes, but you can retrieve your columns in any order. For example:
>> create table t (a int, b int, c int, d int);
>> alter table t add column e int;
> What if they're using some kind of application which reads the
> database metadata and automatically generates a form based on the
> columns present in the table?

You could use a temporary table, copy the data there, drop the
original table and recreate it with the new column with a suitable
default and put back the data in the old columns like this:

  insert into t2 (oldcol1, oldcol2, ..) select * from tmptab;


View raw message