Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: How to reorder fields in a table

Re: How to reorder fields in a table

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 23 Jul 2001 18:23:57 -0700
Message-ID: <9jiind01g38@drn.newsguy.com>

In article <3B55E6A0.CE081CB8_at_hotmail.com>, ewarmoth says...
>
>When I alter a table to add new fields, the fields are put at the end of
>the table. Is there a way to add a field between two existing ones? Or
>am I stuck with them at the end?
>
>If I were to drop the table and re-create it, I would lose the data,
>right?
>
>Thanks very much,
>Emily

This is what views are for.

alter table t add some_column_that_should_be_in_the_middle int;

rename t to t_table;
create view t as select c1, some_column_that_should_be_in_the_middle , c2 from t_table;

do the grants on t again and your applications will never know they are using a view and not a table.

--
Thomas Kyte (tkyte@us.oracle.com)             http://asktom.oracle.com/ 
Expert one on one Oracle, programming techniques and solutions for Oracle.
http://www.amazon.com/exec/obidos/ASIN/1861004826/  
Opinions are mine and do not necessarily reflect those of Oracle Corp 
Received on Mon Jul 23 2001 - 20:23:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US