SQL语句创建表格时出问题了,麻烦各位帮忙看看,很急,谢谢啦
use StudentMIS
--创建学院表
create table DepartmentName
(
DepID int primary key,
DepName varchar(100) not null
)
insert into DepartmentName values(0,'全部院系')
insert into DepartmentName values(1,'数学与软件科学学院')
insert into DepartmentName values(2,'计算机科学学院')
insert into DepartmentName values(3,'物理与材料科学学院')
insert into DepartmentName values(4,'电子工程学院')
insert into DepartmentName values(5,'文学学院')
insert into DepartmentName values(6,'外语学院')
--创建班级表
create table Class
(
ClassID int primary key,
ClassName varchar(10) not null,
DepID int foreign key references DepartmentName(DepID)
)
insert into Class values(0,'全校班级',0)
insert into Class values(1,'1',1)
insert into Class values(2,'2',1)
insert into Class values(3,'3',1)
insert into Class values(4,'4',1)
insert into Class values(5,'1',2)
insert into Class values(6,'2',2)
insert into Class values(7,'3',2)
insert into Class values(8,'1',3)
insert into Class values(9,'2',3)
insert into Class values(10,'1',4)
insert into Class values(11,'2',4)
insert into Class values(12,'3',4)
insert into Class values(13,'1',5)
insert into Class values(14,'2',5)
insert into Class values(15,'1',6)
insert into Class values(16,'2',6)
create table TeachersLogin
(
--设置自增ID
TeacherID int identity(1,1) primary key,
--用作用户名
TeacherNum varchar(200) not null,
TeacherPwd varchar(200) not null,
--老师所在院系
DepID int foreign key references DepartmentName(DepID)
)
insert into TeachersLogin values('teacher001','123456',6)
insert into TeachersLogin values('teacher002','123456',3)
--创建学生详细信息表
create table StudentsDetails
(
Stu_ID int identity(1,1) primary key,
Stu_Num varchar(10),
Stu_Reg bit,
Stu_RegTime datetime,
Stu_Sex varchar(10),
Stu_Score varchar(10),
Stu_Email varchar(100),
Stu_Phone varchar(20),
Stu_Addr varchar(200),
DepID int,
ClassID int foreign key references Class(ClassID)
)
--创建管理员表
create table AdministratorLogin
(
--设置自增ID
AdmID int identity(1,1) primary key,
--用作用户名
Adm_Num varchar(200) not null,
Adm_Pwd varchar(200) not null,
--教师所在院系
DepID int foreign key references DepartmentName(DepID)
)
insert into AdministratorLogin values('050002','123456',2)
有一个AdministratorLogin表(也就是最后一个)没有生成,执行,刷新了好多次没有用 sql?? 表格 数据库 MSSQL
[解决办法]
估计你创建的过程中出错,那句没执行,一段一段执行试试
[解决办法]
DepartmentName
简化为