Radi Radi - 1 year ago 80
SQL Question

How To Handle Table Column Named With Reserved Sql Keyword?

I have an old table that has a column named "RANK" and this name is a keyword in Oracle,
I don't know how this table created and I can't rename this column because it is used by other applications .
Now I need to insert data in this table :

insert into mytbl (RANK)
select RANK from other_table

when executing this query I got the following error :

ORA-00907: missing right parenthesis

Kindly, how can I solve this problem?


Answer Source

Oracle uses double quotes " to escape reserved words.

insert into mytbl ("RANK")
select "RANK" 
from other_table

One other note, Oracle requires correct case as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download