This content has been marked as final. Show 6 replies
one solution please suggest me is correct and also tel me if any good way of correcting the error.It is not correct to use reserved words/keywords as column names. It is confusing and will lead to errors.
If you query V$RESERVED_WORDS then you'll find out:
Where RESERVED indicates whether the keyword cannot be used as an identifier (Y) or whether the keyword is not reserved (N)
SQL> select keyword, reserved from v$reserved_words where keyword = 'VARCHAR2' 2 / KEYWORD R ------------------------------ - VARCHAR2 Y 1 row selected.
You can show data by using double quotes (quoted identifiers), but it's nothing but a cumbersome hack, your collegues will not like you for using a reserved word as a column name, there will be problems and errors sooner or later and they are forced to use quoted identifiers, which is kind of 'silly' (that's an understatement).
Just rename it asap (ALTER TABLE ... RENAME COLUMN ...):
And never ever use a reserved word as an identifier again...
SQL> create table t ("varchar2" varchar2(10)); Table created. SQL> insert into t values ('bla'); 1 row created. SQL> select * from t; varchar2 ---------- bla 1 row selected. SQL> select varchar2 from t; select varchar2 from t * ERROR at line 1: ORA-00936: missing expression SQL> select "varchar2" from t; varchar2 ---------- bla 1 row selected. SQL> alter table t rename column "varchar2" to my_string; Table altered. SQL> select * from t; MY_STRING ---------- bla 1 row selected. SQL> select my_string from t; MY_STRING ---------- bla 1 row selected.