问题遇到的现象和发生背景
想实现RESERVATIONS表的resvKey
的值对应 FLIGHTS / HOTELS / BUS 表的一个主键值,用来表示预约的航班号/车号/宾馆号。但写的sql一直报check有错误
问题相关代码
# 创建预定表
create table RESERVATIONS(
resvNum char(5) primary key,
custID char(5) not null,
resvType int check(resvType in (1, 2, 3)),
resvKey char(5) check(
resvKey in (
select flightNum from FLIGHTS
union select hotelNum from HOTELS
union select BusNum from BUS
)
),
foreign key (custID) references CUSTOMERS(custID)
) CHARSET=utf8;
运行结果及报错内容
[Start] Executing MySQL query
undefined
Error: UNKNOWN_CODE_PLEASE_REPORT: An expression of a check constraint 'reservations_chk_2' contains disallowed function.
[Done] Finished MySQL query.
请问应该怎么修改呀