Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can you use a reserved word? 1

Status
Not open for further replies.

Glowworm27

Programmer
May 30, 2003
587
US
I have a column in SQL named Size, in Oracle this is a reserved word.

In SQL to use a reserved word you wrap [ and ] around the word to use it as a column name. For instance

Code:
Select mytable as [table] from sometable

is there a way to use a reserved word in an Oracle Query some way???

Thanks in Advance

George Oakes
Check out this awsome .Net Resource!
 
Yes, George, you use double quotes. The following code listing show both the errors and the resolution of those errors by using double quotes ("):
Code:
SQL> create table size (size number);
create table size (size number)
             *
ERROR at line 1:
ORA-00903: invalid table name


SQL> create table "SIZE" ("SIZE" number);

Table created.

SQL> insert into size values (1);
insert into size values (1)
            *
ERROR at line 1:
ORA-00903: invalid table name


SQL> insert into "SIZE" values (1);

1 row created.

SQL> select * from SIZE;
select * from SIZE
              *
ERROR at line 1:
ORA-00903: invalid table name


SQL> select * from "SIZE";
         1

1 row selected.
Oracle gurus consider it bad form, however, to resort to this feature.


Let us know if this resolves your need.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Thanks, George. And keep in mind that all references inside of double quotes must always use the same case:
Code:
SQL> select * from "size";
select * from "size"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "Size";
select * from "Size"
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from "SIZE";

      SIZE
----------
         1
That's probably the main reason that we consider double quotes to be poor form...'cause it increases costs and time for programming since you cannot go case insensitive in your programming.

Cheers,

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top