-1

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?

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
Jonathan Chaplin
  • 2,442
  • 1
  • 18
  • 21
  • Did you try using the same approach as when selecting or ordering in your statement to rename it? In all cases you'd need to escape it so it's not treated as a keyword. – Anthony Grist Apr 15 '13 at 15:57

1 Answers1

3

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.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • 1
    All standard compliant DBMS use double quotes to quote reserved words - not only Oracle. –  Apr 15 '13 at 16:03