Thursday, August 20, 2015

Changing position of a column in ORACLE Table

SQL> create table first_table (col1 number, col2 number, col3 number);



Table created.



SQL> desc first_table
 Name                                      Null?    Type

 ----------------------------------------- -------- -------------------

 COL1                                               NUMBER

 COL2                                               NUMBER

 COL3                                               NUMBER



SQL> create table sec_table as select col3, col2, col1 from first_table;



Table created.



SQL> drop table first_table;



Table dropped.



SQL> alter table sec_table rename to first_table;



Table altered.



SQL> desc first_table;

 Name                                      Null?    Type

 ----------------------------------------- -------- -------------------

 COL3                                               NUMBER

 COL2                                               NUMBER

 COL1                                               NUMBER



SQL> 

No comments:

Post a Comment