Mayank Aggarwal
Mayank Aggarwal

Reputation: 139

SQL Oracle error: ORA-00904

I am creating a table and I typed this command:

SQL> create table accident(report_number integer primary key,
  2  date varchar(20),
  3  location varchar(20));

I got this error:

date varchar(20),
*
ERROR at line 2:
ORA-00904: : invalid identifier

Can anyone tell me where the error is and how to rectify it?

Upvotes: 1

Views: 223

Answers (2)

sameh.q
sameh.q

Reputation: 1709

Date is a reserved word, to use it for column names, surround it with quotas "column-name"

ex:

create table abcd(
"date" date
);

insert into abcd values (sysdate);

select "date" from abcd;

But note that when using quoats, the column names will be case sensitive

ex:

select "Date" from abcd will result in an "Date": invalid identifier

Upvotes: 0

Gary Myers
Gary Myers

Reputation: 35401

DATE is a reserved word and can't be used as a column name.

Upvotes: 1

Related Questions