SQL数据库创建学生、教师、选课表

创建学生表

create table student (
 sno char(14) primary key,
 sname char (10) not null,
 ssex char(2),
 sage tinyint,
 sdept varchar(20),
 spassword tinyint,
 )

创建教师表

create table teacher (
 tno char(14) primary key,
 tname char (10) not null,
 tsex char(2),
 tage tinyint,
 sdept varchar(20),
 spassword tinyint,
 )

创建选课表

create table course (
 cno char(10),
 sno char(14) not null,
 tno char(14) not null,
 cyear tinyint,
 cterm tinyint,
 grade tinyint,
 primary key(sno,tno),
 foreign key(sno) references student(sno),
 foreign key(tno) references teacher(tno),
 )

更多推荐

SQL数据库创建学生、教师、选课表