我有3个表Customer,Store和Receipt。 Receipt表必须有一个receiptno,它是主键。 Receipt表还有属性customerid和storeid,如何指定customerid是引用customer表中customerid的外键,storeid是在Stores表中引用storeid的外键?
答案 0 :(得分:1)
create table Customer (customerid int primary key);
create table Store (storeid int primary key);
create table Receipt
(
receiptno int primary key
,customerid int references Customer (customerid)
,storeid int references Store (storeid)
);