Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Column Rename
Bob Fazio <rfazio_at_home.com.nospam> wrote:
> With 8.0 you can't rename a column at all. With 8.1 (8i) I believe so,
> haven't tried.
> --
> Robert Fazio, Oracle DBA
> rfazio_at_home.com
> remove nospam from reply address
> http://24.8.218.197/
> "Nasir" <nmajeed_at_prosweb.com> wrote in message
> news:B993834534D63B21.954B8F509C198AC5.B50C18AB58EFD953_at_lp.airnews.net...
>> Hi, >> >> Is it possible to rename a column when the table has data in it ? >> >> Thanks, >> Nasir >> nmajeed_at_prosrm.com >> >> >>
Hi !
I tried it in 8i, but I couldn't find a statement like ALTER TABLE RENAME COLUMN ...
I did it that way (example):
original table:
SQL> desc test1
Name Null? Type ------------------------------- -------- ---- A VARCHAR2(10) B VARCHAR2(10)
to rename column B to C:
SQL> alter table test1 add c varchar2(10);
Table altered.
SQL> update test1 set c=b;
3 rows updated.
SQL> alter table test1 drop column b;
Table altered.
SQL> desc test1
Name Null? Type ------------------------------- -------- ---- A VARCHAR2(10) C VARCHAR2(10)
note that if you have an index on B you have to recreate it on C !!!
hth,
Harry.
Received on Wed Jun 14 2000 - 00:00:00 CDT