|
Re: can we rename a column in 9i ? [message #53070 is a reply to message #53064] |
Tue, 27 August 2002 07:52 |
André ALIMBA
Messages: 16 Registered: April 2002
|
Junior Member |
|
|
You cannot rename directly a column name by using RENAME command.
So, you have 2 solutions :
SOLUTION I
==========
1) add a new column with the new name you want (same type, same caracteristics than the old column)
- alter table nom_table add (new_col_name varachar2(5));
2) Put the value of old column in the new column
- update nom_table set new_col_name = old_col_name;
3) Drop the old column
- alter table nom_table drop column old_col_name;
SOLUTION 2
==========
1)Create a new table having the characteristics from the old
- CREATE TABLE new_name_table (new_col_name, colname2, colname3)AS SELECT old_col_name, colname2, colname3 FROM old_name_table;
2) Drop the old table :
- DROP TABLE old_name_table;
3) Rename new table with the name from the old table
- RENAME new_name_table TO old_name_table;
ATTENTION :
=========
old_col_name must no reference in others tables (referential constraints integrity)
|
|
|
|