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

Home -> Community -> Usenet -> c.d.o.server -> Re: Rename a column

Re: Rename a column

From: Jonathan Gennick <gennick_at_worldnet.att.net>
Date: Wed, 22 Apr 1998 03:01:35 GMT
Message-ID: <6hjmj6$5bn@bgtnsc02.worldnet.att.net>


On Mon, 20 Apr 1998 21:00:35 +0800, "Lui Yuan Tze" <ssplyt_at_pacific.net.sg> wrote:

>How does one rename a table column ?

You can't. You either have to recreate the table, or fudge a bit. If you don't want to recreate the table, or don't have the time, you can do the following:

  1. Create a new column with the name you want. Make sure it's the correct datatype.
  2. Copy the values from the old column to the new. Use a SELECT like this:

        UPDATE table set new_column = old_column;

	3. Make sure that you make the old column
	nullable.

	4. Tell everyone to use the new column name.
	The old column will just linger on but won't be used.

	5. You might also consider a trigger that aborts
	on any attempt to insert a value into the old column.
	I usually don't do this. If I'm concerned about this,
	then I recreate the table.

Sometimes I'll do steps 1-4 above as a quick measure to satisify the programmers, users, etc, and later I'll come back and rebuild the table without the old column.

regards,

Jonathan Received on Tue Apr 21 1998 - 22:01:35 CDT

Original text of this message

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