今天写了好多sql语句,包括对外键的使用,多主键的设置
CREATE TABLE student ( sno CHAR(8) PRIMARY KEY COMMENT '学号', sname VARCHAR(20) COMMENT'姓名', sex CHAR(2) COMMENT '性别', sdept VARCHAR(20) COMMENT '所在系' );
CREATE TABLE course(
cno CHAR(6) PRIMARY KEY COMMENT '课程号',
cname VARCHAR(20) COMMENT '课程名'
);
CREATE TABLE sc (
sno CHAR(8) COMMENT '学号', cno CHAR(6) COMMENT '课程号',
grade INT NOT NULL COMMENT '成绩',
PRIMARY KEY (sno, cno),
FOREIGN KEY (sno) REFERENCES student(sno),
FOREIGN KEY (cno) REFERENCES course(cno)
);
标签:COMMENT,10,VARCHAR,sno,2024,KEY,cno,第四十六,CHAR From: https://www.cnblogs.com/xuechenhao173/p/18185441