CREATE TABLE student
(sno CHAR(10)NOT NULL PRIMARY KEY,
sname VARCHAR(8),
ssex CHAR(2),
sbirthday datetime(2),
saddress VARCHAR(50),
sdept CHAR(16),
speciality VARCHAR(20)
);
CREATE TABLE course
(cno CHAR(5)NOT NULL PRIMARY KEY,
cname VARCHAR(20)NOT NULL
);
CREATE TABLE sc
(sno CHAR(10)NOT NULL,
cno CHAR(5)NOT NULL,
degree DECIMAL(4,1),
CONSTRAINT n1 PRIMARY KEY(sno,cno),
CONSTRAINT n2 FOREIGN KEY(sno)REFERENCES student(sno), CONSTRAINT n2 FOREIGN KEY(cno)REFERENCES course(cno) );
CREATE TABLE teacher
(tno CHAR(3)NOT NULL PRIMARY KEY,
tname VARCHAR(8)NOT NULL,
tsex CHAR(2),
tbirthday DATE,
tdept CHAR(16)
);
CREATE TABLE teaching
(cno CHAR(5)NOT NULL,
tno CHAR(3)NOT NULL,
cterm TINYINT(1),
CONSTRAINT n1 PRIMARY KEY(cno,tno),
CONSTRAINT n2 FOREIGN KEY(cno)REFERENCES course(cno), CONSTRAINT n3 FOREIGN KEY(tno)REFERENCES teacher(tno) );
表9 教师表teacher
tno tname tsex tbirthday tdept
101 李新 男 1977-01-12 计算机⼯程系102 钱军 ⼥ 1968-06-04 计算机⼯程系
CREATE TABLE student
(sno CHAR(10)NOT NULL PRIMARY KEY,
sname VARCHAR(8),
ssex CHAR(2),
sbirthday datetime(2),
saddress VARCHAR(50),
sdept CHAR(16),
speciality VARCHAR(20)
);
foreign key references用法
CREATE TABLE course
(cno CHAR(5)NOT NULL PRIMARY KEY,
cname VARCHAR(20)NOT NULL
);
②利⽤drop table命令实现(3)中的④。DROP TABLE student:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论