Foreign key to composite key

我怕爱的太早我们不能终老 提交于 2019-11-30 19:09:47

If you reference a composite primary key, your foreign key also needs to contain all those columns - so you need something like:

FOREIGN KEY (available_trip_code, date) 
            REFERENCES available_trip (trip_code, date)

If you don't already have all those columns present in your table, then you'll need to add them.

alter table booking add constraint FK_Booking_TripAndDate
    foreign key (available_trip_code,date)
    references available_trip(trip_code, date)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!