Question

I have a table called CONTACT_DATA in Oracle, and it has a column called NUMBER. I would like to rename this field to PHONE_NUMBER however, the following does not work because NUMBER is a reserved word in Oracle:

ALTER TABLE CONTACT_DATA RENAME COLUMN NUMBER TO PHONE_NUMBER;

I've looked on these forums, and found how to select and order by a column that is a reserved word. However, in this instance I'd prefer to rename the column instead. Also, I'd like to keep the existing data so dropping the table and re-creating it is not an option. I'm using Oracle version 11.2 Can anyone help?

Was it helpful?

Solution

Have you tried:

ALTER TABLE CONTACT_DATA RENAME COLUMN "NUMBER" TO PHONE_NUMBER;

Oracle uses the double quotes as an escape character for this purpose.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top