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: Dave O'Keeffe <DOKeeffe_at_n0spam.cableinet.co.uk>
Date: Tue, 21 Apr 1998 20:54:30 +0100
Message-ID: <353CF976.62D7@n0spam.cableinet.co.uk>


If you cannot afford the time immediately to drop and recreate the table, then you can do the following:
(someone pull me up if I miss a step)

  1. Rename the table to something else using the rename command
  2. Create a view on the table, only in the view rename the column to want you want e.g. RENAME TAB1 TO OLD_TAB1; CREATE VIEW TAB1 (COLB) AS SELECT COLA FROM OLD_TAB1; You still need to grant access to the new view to all requisite users/roles. As it is a view on a single table, users can continue to update the database through it. At your convenience (i.e. get the DBA to work at the weekend!) get the table properly recreated and drop the view.

Dave O'Keeffe

Tim Hall wrote:
>
> On Mon, 20 Apr 1998 21:00:35 +0800, "Lui Yuan Tze"
> <ssplyt_at_pacific.net.sg> wrote:
>
> >Hi,
> >How does one rename a table column ?
> >
> >Cheers
> >
>
> You can't. You have to rename the table, then create a new table with
> your desired new column in it and copy the data across (You can do
> this with create table <TABLE> as select * from <OLD_TABLE>)
>
> You will also have to recreate your indexes, keys, constraints etc.
>
> BTW, Message to the Gods of comp.database.oracle.* - Where is the FAQ
> for this group? Is this question in it, 'cause it comes up rather a
> lot :)
>
> Tim Hall, Indus International (was TSW International)
> tim.hall (at) iint.com
> http://www.indusworld.com
>
> Replace domain name with the iint.com before replying via email!

--
For email replys remove "n0spam." from the above address Received on Tue Apr 21 1998 - 14:54:30 CDT

Original text of this message

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