Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to change a field name?
Assume your original table is my_table (col1, col2, col3) and you want to change the name of col3 to col4. Try this:
CREATE TABLE my_new_table
AS
SELECT col1, col2, col3 AS col4
FROM my_table;
Do a DESC[RIBE] my_new_table to make sure you got what you wanted (both for column names and data !).
DROP my_table;
RENAME my_new_table TO my_table;
Note: I assumed a very simple case where you do not have any referential integrity constraints between my_table or my_table.col3 and any other child table(s). If you do have such constraints, e-mail me with details and I will help you.
I hope this helps.
Michael Serbanescu
Senior Consultant, MIACO Corporation
Received on Sat Mar 22 1997 - 00:00:00 CST