当前位置: 代码迷 >> Sql Server >> 有个简单的有关问题,不知道如何接军
  详细解决方案

有个简单的有关问题,不知道如何接军

热度:33   发布时间:2016-04-27 13:04:18.0
有个简单的问题,不知道怎么接军

--学生表

create table Student(
stu_id char(10) primary key,
stu_pwd char(6) ,
stu_role char(6) check (stu_role in ('学生')) default '学生'
);
insert into Student (stu_id,stu_pwd,stu_role) values('100522201','201','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522202','202','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522203','203','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522204','204','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522205','205','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522206','206','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522207','207','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522208','208','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522209','209','学生');
insert into Student (stu_id,stu_pwd,stu_role) values('100522210','210','学生');


--教师表

create table Teacher (
teacher_id char(10) primary key,
teacher_pwd char(6),
teacher_role char(6) check (teacher_role in ('教师')) default '学生');
insert into Teacher (teacher_id,teacher_pwd,teacher_role) values('200522201','201','教师');
insert into Teacher (teacher_id,teacher_pwd,teacher_role) values('200522202','202','教师');
insert into Teacher (teacher_id,teacher_pwd,teacher_role) values('200522203','203','教师');


--管理员表

create table Sa (
sa_id char(10) primary key,
sa_pwd char(6),
sa_role char(6) check (sa_role in ('管理员')) default '管理员'
);
insert into Sa(sa_id,sa_pwd,sa_role) values('91101','101','管理员');
insert into Sa(sa_id,sa_pwd,sa_role) values('91102','102','管理员');

--学生信息表


create table Stuinf(
stu_id char(10),
stu_name varchar(50),
stu_sex char(2),check (stu_sex in ('男','女'))default '男', 这里提示关键字 'default' 附近有语法错误。
stu_tel char(20),
stu_spe char(30),
stu_colleae char(30) default '计算机',
foreign key (stu_id) references Student(stu_id)
)

--教师信息表

create table teacheinf(
teacher_id char(10),
teacher_name varchar(50),
teacher_sex char(2) check (teacher_sex in ('男','女'))default '男', 这里怎么就执行成功了?跟上一个写的是一样的啊
teacher_tel char(20),
teacher_type varchar(30)
foreign key (teacher_id) references Teacher(teacher_id)
)

--

create table Course(
course_id char(20),
course_name char(5),
teacher_name varchar(30),
mark int between 0 and 10, 这里提示有错误,该怎么写啊?关键字 'between' 附近有语法错误。
times int >0,
adress char(30)
)

--选课表

create table Choosecs (
stu_id char(10),
course_id char(20),
foreign key (stu_id) references Student(stu_id),
foreign key (course_id) references Course(course_id)
)

create table Messgae (
sender_id char(10) foreign key (sender_id) references (???),
accept_id char(10) foreign key (accept_id) references (???),
message text,
sendtime char(30)
)



再帮忙检查下后两个表有没有错误呢,多谢各位大神帮忙哦!

------解决方案--------------------
尼玛,怎么跟我现在做的这个项目的表这么相似??不过我是19张表
------解决方案--------------------

SQL code
create table Stuinf(stu_id char(10),stu_name varchar(50),stu_sex char(2),(去掉这个逗号)check (stu_sex in ('男','女'))default '男', 这里提示关键字 'default' 附近有语法错误。stu_tel char(20),stu_spe char(30),stu_colleae char(30) default '计算机',foreign key (stu_id) references Student(stu_id))
------解决方案--------------------
SQL code
create table Course(course_id char(20),course_name char(5),teacher_name varchar(30),mark int check(mark  between 0 and 10)(应该这样写), 这里提示有错误,该怎么写啊?关键字 'between' 附近有语法错误。times int >0,adress char(30))
  相关解决方案