sql语句,外键约束

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/BINGDUCAIJUN/article/details/50435747

外键约束

CREATE table userinfo(
userid int  PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) not null,
usertel VARCHAR(11) not null,
userpwd VARCHAR(20) not null,
usertouxiang  VARCHAR(100) not null,
chargeid int(1) check (chargeid=1 or chargeid=2 ) ,foreign key (chargeid)references chargetype(chargeid),
authorityid int(1) check (authorityid =1 or authorityid =2), foreign key (authorityid) references authoritytype(authorityid),
onlinestateid int(1) check(onlinestateid=1 or onlinestateid=2),foreign key (onlinestateid)  references onlinestatetype(onlinestateid)
);

展开阅读全文

没有更多推荐了,返回首页