Reputation: 21
I am creating a simple table in toad for Oracle:
CREATE TABLE medcine
(
id NUMBER,
name VARCHAR2(20 CHAR) NOT NULL,
price NUMBER,
supplier_id NUMBER NOT NULL,
company_id NUMBER NOT NULL,
pre_date DATE DEFAULT sysdate NOT NULL,
Exp_date DATE DEFAULT sysdate NOT NULL,
sell-price NUMBER,
effective_material VARCHAR2(15 CHAR)
);
but when I run it I get this error:
Error at line 3
ORA-00902: invalid datatype
Upvotes: 1
Views: 849
Reputation: 15991
You have a typo:
sell-price
should be
sell_price
It is the -
that is being rejected, because the parser expects a datatype at that position.
By the way, some reformatting must have changed the line numbering, as SQL*Plus for example reports the exact position of the error:
SQL> CREATE TABLE medcine
2 (
3 id NUMBER,
4 name VARCHAR2(20 CHAR) NOT NULL,
5 price NUMBER,
6 supplier_id NUMBER NOT NULL,
7 company_id NUMBER NOT NULL,
8 pre_date DATE DEFAULT sysdate NOT NULL,
9 Exp_date DATE DEFAULT sysdate NOT NULL,
10 sell-price NUMBER,
11 effective_material VARCHAR2(15 CHAR)
12 );
sell-price NUMBER,
*
ERROR at line 10:
ORA-00902: invalid datatype
PL/SQL Developer and SQL Developer both highlight the hyphen character when reporting the error; PL/SQL Developer also places the cursor on it. I expect Toad does something similar.
Also, possibly the table should be named medicine.
Upvotes: 4