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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to change a field name?

Re: How to change a field name?

From: Mserban <mserban_at_aol.com>
Date: 1997/03/22
Message-ID: <19970322080601.DAA04561@ladder01.news.aol.com>#1/1

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

Original text of this message

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