简体   繁体   中英

Keep getting a missing right parenthesis (ORA-00907) error in Oracle

Just recently started learning SQL and got assigned some homework. I have to make a few tables but I keep getting an ORA-00907 missing right parenthesis error but I see no syntax issues.

This is my code for one of the tables I have to make:

CREATE TABLE DRIVER 
(
    DRIVER# INT NOT NULL PRIMARY KEY,
    DNAME VARCHAR(255), 
    SALARY INT,
    CERT_DATE DATE,
    DEPOT# INT FOREIGN KEY REFERENCES DEPOT(DEPOT#)
);

Your foreign key constraint at the end of the table definition (for column DEPOT# ) is an inline constraint: it is defined "in line" with the column definition.

The syntax for inline foreign key constraints does not include the FOREIGN KEY keywords. The fix is trivial: delete those two words, then the statement should work.

As an aside, please note that for silly reasons the preferred data type for strings in Oracle database is VARCHAR2 rather than VARCHAR . You may either research "why" on your own, ask your instructor, use VARCHAR2 without asking why, or use VARCHAR knowing that Oracle recommends explicitly against its use.

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