问题
I need help with this it keeps giving the same error in Oracle SQL Developer.
Error starting at line : 15 in command -
CREATE TABLE B_BOOKING (
booking_number int NOT NULL PRIMARY KEY,
date_booked date,
performance_order int,
base_pay int,
band_number int,
concert_number int, FOREIGN KEY REFERENCES B_CONCERT(concert_number)
)
Error at Command Line : 21 Column : 34 Error report - SQL Error: ORA-00906: missing left parenthesis 00906. 00000 - "missing left parenthesis" *Cause:
*Action:
回答1:
You appear to be trying to declare a foreign key inline and have the syntax incorrect, you want:
CREATE TABLE B_BOOKING (
booking_number int PRIMARY KEY,
date_booked date,
performance_order int,
base_pay int,
band_number int,
concert_number int REFERENCES B_CONCERT(concert_number)
)
Also, you do not need a NOT NULL
constraint on a PRIMARY KEY
column.
Alternatively you can declare the constraint as:
CREATE TABLE B_BOOKING (
booking_number int PRIMARY KEY,
date_booked date,
performance_order int,
base_pay int,
band_number int,
concert_number int,
CONSTRAINT constraint_name FOREIGN KEY ( concert_number )
REFERENCES B_CONCERT(concert_number)
)
来源:https://stackoverflow.com/questions/46857105/create-table-error-oracle-sql