使用 SQL 语句创建 School 数据库(包括参数)、 TblClass 表、 TblStudent 表。 并向其中填入数据。
创建 School 数据库(包括参数)
create database School
on primary
(
name='School',
filename='F:\SQL Server\School.mdf',
size=10mb,
filegrowth=10,
maxsize=100mb
)
log on
(
name='School_log',
filename='F:\SQL Server\School_log.ldf'
)
TblClass 表:
create table TblClass
(
clsId int identity(1,1) primary key,
clsName nvarchar(50) not null,
clsDiscription nvarchar(50)
)
insert into TblClass (clsName,clsDiscription) values ('高一一班','快班')
insert into TblClass (clsName,clsDiscription) values ('高一二班','中班')
insert into TblClass (clsName,clsDiscription) values ('高一三班','慢班')
insert into TblClass (clsName,clsDiscription) values ('高二一班','快班')
insert into TblClass (clsName,clsDiscription) values ('高二二班','中班')
insert into TblClass (clsName,clsDiscription) values ('高二三班','慢班')
TblStudent 表:
create table TblStudent
(
stuId int identity(1,1) primary key,
clsId int not null, --班级外键
stuName nvarchar(50) not null,
stuAge int not null,
stuNo numeric(18,0),--身份证号,十八位数字
stuGender bit not null default(1),
stuEmail varchar(50),
stuBirthday datetime
)
insert into TblStudent (clsId,stuName,stuAge,stuGender,stuNo,stuBirthday) values (1,'刘备',20,1,123456789012345678,'1987-5-6')
insert into TblStudent (clsId,stuName,stuAge,stuGender,stuNo,stuBirthday) values (1,'关羽',19,1,123456789012345671,'1988-8-6')
insert into TblStudent (clsId,stuName,stuAge,stuGender,stuNo,stuBirthday) values (1,'张飞',18,1,123456789012345672,'1989-5-19')
insert into TblStudent (clsId,stuName,stuAge,stuGender,stuNo,stuBirthday) values (4,'曹操',22,1,123456789012345673,'1985-12-6')
insert into TblStudent (clsId,stuName,stuAge,stuGender,stuNo,stuBirthday) values (4,'夏侯惇',22,1,123456789012345674,'1985-3-6')
insert into TblStudent (clsId,stuName,stuAge,stuGender,stuNo,stuBirthday) values (4,'华佗',50,1,12345678901234565,'1957-1-16')
insert into TblStudent (clsId,stuName,stuAge,stuGender,stuNo,stuBirthday) values (4,'甄姬',18,2,12345678901234565,'1989-8-8')