Create Table Error - Oracle SQL

后端 未结 1 1970
栀梦
栀梦 2021-01-28 18:25

I need help with this it keeps giving the same error in Oracle SQL Developer.

Error starting at line : 15 in command -

CREAT         


        
相关标签:
1条回答
  • 2021-01-28 18:40

    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)
    )
    
    0 讨论(0)
提交回复
热议问题