db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: How to insert new column in front of exsiting column?
Date Thu, 14 May 2009 15:06:00 GMT
You can declare a view on the base table which returns the columns in 
the order you need. DatabaseMetaData.getColumns() will return the view's 
columns in the desired order.

Hope this helps,

Dag H. Wanvik wrote:
> 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;
> Dag

View raw message