create table student--創建student數據表
(
s_no char(10) not null, --學號
s_name nchar(10), --姓名
s_sex char(2), --性別
borndate smalldatetime,--出生日期
ClassName nvarchar(50), --班級名稱
Telephone varchar(11), --電話號碼
EnrollDate smallDateTime,--註冊日期
Address nvarchar(50), --地址
Comment text --備註
)
create table teacher
(
t_no char(10) not null,
t_name nchar(10),
t_sex char(2),
BornDate smallDateTime,
Dept_No char(10)
)
create table Course
(
c_No char(10) not null,
c_Name nvarchar(30),
c_Type nchar(10),
c_Credit Decimal(5,1),
c_Des text
)
create table T_User
(
UserName char(10) not null,
Password char(10),
Grade nchar(10),
Description text
)
create table t_c
(
t_no char(10) not null,
c_no char(10) not null,
Semester nvarchar(30)
)
create table s_c
(
s_no char(10) not null,
c_no char(10) not null,
score int
)
create table Dept
(
d_no char(10) not null,
DeptName nvarchar(20),
Duty nvarchar(50)
)
use Stu
go
--修改數據表
alter table student
add idcard char(18) --增加身份證列
--修改數據表刪除列
alter table student
drop column idcard
--修改數據表修改數據類型
alter table student
alter column borndate datetime
--插入數據
--向student表中插入數據
insert into student values('05331101','張曼','女','1993-05-03 00:00:00',
'計算機應用','18602354822','2005-09-01 00:00:00','遼寧瀋陽',null)
insert into student values('05331102','劉迪','女','1994-10-20 00:00:00',
'計算機應用','13893220935','2005-09-01 00:00:00','遼寧撫順',null)
insert into student values('05331103','劉凱','男','1982-05-30 00:00:00',
'計算機應用','18641330245','2005-09-01 00:00:00','遼寧鞍山',null)
insert into student values('05331104','王越','男','1991-09-19 00:00:00',
'計算機應用','18641320940','2005-09-01 00:00:00','遼寧營口',null)
insert into student values('05331105','李楠','女','1995-03-16 00:00:00',
'計算機應用','18641328449','2005-09-01 00:00:00','遼寧錦州',null)
insert into student values('05331106','胡棟','男','1992-07-03 00:00:00',
'計算機應用','18641326996','2005-09-01 00:00:00','遼寧瀋陽',null)
insert into student values('06102534','楊超','男','1990-10-01 00:00:00',
'機械設計','13893245623','2006-09-01 00:00:00','河北石家莊',null)
--向教師表中插入數據
insert into teacher values('0001','王慶','男','1965-3-9','1')
insert into teacher values('0002','林志玲','女','1980-7-12','2')
insert into teacher values('0003','黎明','男','1975-5-18','3')
insert into teacher values('0004','郭靖','男','1953-10-30','4')
insert into teacher values('0005','黃蓉','女','1973-8-27','1')
insert into teacher values('0006','林黛玉','女','1983-5-27','2')
--向成績表中錄入數據
insert into s_c values('05331101','0001',95)
insert into s_c values('05331101','0002',98)
insert into s_c values('05331101','0003',89)
insert into s_c values('05331102','0001',93)
insert into s_c values('05331102','0002',99)
insert into s_c values('05331102','0003',95)
insert into s_c values('05331103','0001',84)
insert into s_c values('05331103','0002',80)
insert into s_c values('05331103','0003',94)
--向部門表中插入數據
insert into Dept values('1','人事處','處理人事工作')
insert into Dept values('2','學生處','處理學生工作')
insert into Dept values('3','教務處','處理教學相關工作')
insert into Dept values('4','校園管理處','處理學校所有後勤輔助工作')
insert into Dept values('5','機械與運載學院','教學單位')
insert into Dept values('6','信息與控制學院','教學單位')
insert into Dept values('7','經濟與管理學院','教學單位')
--向課程表中插入數據
insert into Course values('0001','大學英語','考試','10','英語相關知識')
insert into Course values('0002','數據庫原理及應用','考試','7','數據庫相關知識')
insert into Course values('0003','數據結構','考查','5','程序設計基礎')
--向授課表中插入數據
insert into t_c values('0001','0001','2011-2012(1)')
insert into t_c values('0001','0002','2011-2012(2)')
insert into t_c values('0002','0001','2011-2012(1)')
insert into t_c values('0003','0001','2011-2012(1)')
insert into t_c values('0004','0002','2011-2012(2)')
insert into t_c values('0005','0002','2011-2012(2)')
insert into t_c values('0006','0003','2011-2012(2)')
insert into t_c values('0006','0002','2011-2012(1)')