Home » RDBMS Server » Server Administration » Renaming columns
Renaming columns [message #371064] Mon, 21 August 2000 08:00 Go to next message
ann
Messages: 24
Registered: August 2000
Junior Member
Hi!

Is there anyway to rename a column in a table? I´m using ORACLE 8i. Can I use the RENAME Syntax and if that case, how do I write it?

Thanks.

Regards Ann
Re: Renaming columns [message #371130 is a reply to message #371064] Sat, 02 September 2000 12:44 Go to previous messageGo to next message
Jeff
Messages: 63
Registered: July 1999
Member
I am pretty sure you can not rename columns but you can drop them and recreate a column with the same name. The only issue is that you will lose the data in the dropped column.
Re: Renaming columns [message #371131 is a reply to message #371064] Sun, 03 September 2000 00:14 Go to previous messageGo to next message
abdulateaf
Messages: 1
Registered: September 2000
Junior Member
you can rename columns ( copy table to another table with data and you can rename coloumns

select * from table
as new names columns
Re: Renaming columns [message #371145 is a reply to message #371064] Wed, 06 September 2000 14:51 Go to previous messageGo to next message
Irving
Messages: 13
Registered: September 2000
Junior Member
Hi,

let me share you a possible solution:

1st step (Adding the new field)

ALTER TABLE YourTable ADD NewField Datatype;

2nd step (Copying data from old field to new field)

I let you the implementation =)

3rd step (Marking OLD column as unused) - Optional

ALTER TABLE YourTable SET UNUSED COLUMN OldField;

4th step (Deleting columns / unused columns)

ALTER TABLE YourTable DROP UNUSED COLUMNS;

or

ALTER TABLE YourTable DROP COLUMN OldField CASCADE CONSTRAINTS (only to foreign keys)

Regards =)
Re: Renaming columns [message #371175 is a reply to message #371064] Wed, 13 September 2000 01:56 Go to previous message
Mahesh Pednekar
Messages: 28
Registered: August 2000
Junior Member
You first crate new columns, then copy the data from old columns to new columns then drop the old columns. You will not loose the data.
Thanx
Previous Topic: Which is the best Microsoft SQLServer or Oracle ??
Next Topic: Using SQL - Can u print all the dates between two given dates
Goto Forum:
  


Current Time: Thu Mar 28 17:08:26 CDT 2024