简体   繁体   中英

How to trace syntax errors in CREATE TABLE statements in Oracle SQL Developer?

I'm trying to run this script and for the life of me I can't get it working.. This is the information I was given to create the script, and my professor told me not to use INT, instead to use number or varchar. Still doesn't work.. Below that is the script I created, along with the error code. What am I doing wrong?

INV_NUMBER is an integer,               
LINE_NUMBER is an integer,              
P_CODE is a varchar with length 10              
LINE_UNITS is a number with length 9 and two digits after decimal point             
LINE_PRICE  is a number with length 9 and two digits after decimal point                


CREATE TABLE LINE (
INV_NUMBER int,
LINE_NUMBER int,
P_CODE VARCHAR (10),
LINE_UNITS NUMBER(9,2),
LINE_PRICE NUMBER(9,2),
);

Error starting at line : 1 in command -
CREATE TABLE LINE (
INV_NUMBER int,
LINE_NUMBER int,
P_CODE VARCHAR (10),
LINE_UNITS NUMBER(9,2),
LINE_PRICE NUMBER(9,2),
)

Error report - ORA-00904: : invalid identifier 00904. 00000 - "%s: invalid identifier" *Cause:
*Action:

Reformatting your code into a legible state makes the error far more clear:

CREATE TABLE LINE ( 
  INV_NUMBER int
  , LINE_NUMBER int
  , P_CODE VARCHAR (10)
  , LINE_UNITS NUMBER(9,2)
  , LINE_PRICE NUMBER(9,2)
  , 
);

That trailing comma is your problem. Remove it and your CREATE should work.

CREATE TABLE LINE ( 
  INV_NUMBER int
  , LINE_NUMBER int
  , P_CODE VARCHAR (10)
  , LINE_UNITS NUMBER(9,2)
  , LINE_PRICE NUMBER(9,2)
);

you have a comma at the end there.. also the professor told you to not use 'INT', but it looks like you're still using it... ? why?...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM