1蜂林、安裝工具:mysql+SQLyog
2傀广、建表+插入數(shù)據(jù)
學(xué)生表(Student)遣臼、課程表(Course)、成績(jī)表(Score)以及教師信息表(Teacher)
表結(jié)構(gòu)如下:
(1)Student (學(xué)生表)
CREATE TABLE student
(
sno VARCHAR(3) NOT NULL,
sname VARCHAR(4) NOT NULL,
ssex VARCHAR(2) NOT NULL,
sbirthday DATETIME,
class VARCHAR(5)
)
(2)Course(課程表)
CREATE TABLE course
(
cno VARCHAR(5) NOT NULL,
cname VARCHAR(10) NOT NULL,
tno VARCHAR(10) NOT NULL
)
(3)Score(成績(jī)表)
CREATE TABLE score
(
sno VARCHAR(3) NOT NULL,
cno VARCHAR(5) NOT NULL,
degree NUMERIC(10, 1) NOT NULL
)
(4)Teacher(教師表)
CREATE TABLE teacher
(
tno VARCHAR(3) NOT NULL,
tname VARCHAR(4) NOT NULL,
tsex VARCHAR(2) NOT NULL,
tbirthday DATETIME NOT NULL,
prof VARCHAR(6),
depart VARCHAR(10) NOT NULL
)
表的數(shù)據(jù)如下:
(1)student
方法一:
INSERT INTO student(sno,sname,ssex,sbirthday,class) values
(108 ,'曾華','男' ,1977-09-01,95033),
(105 ,'匡明','男' ,1975-10-02,95031),
(107 ,'王麗','女' ,1976-01-23,95033),
(101 ,'李軍','男' ,1976-02-20,95033),
(109 ,'王芳','女' ,1975-02-10,95031),
(103 ,'陸君','男' ,1974-06-03,95031)
方法二:
insert into student values('108','曾華','男','1977-09-01',95033);
insert into student values('105','匡明','男','1975-10-02',95031);
insert into student values('107','王麗','女','1976-01-23',95033);
insert into student values('101','李軍','男','1976-02-20',95033);
insert into student values('109','王芳','女','1975-02-10',95031);
insert into student values('103','陸軍','男','1974-09-03',95031);
(2)course
INSERT INTO course (cno,cname,tno) values
('3-105', '計(jì)算機(jī)導(dǎo)論','825'),
('3-245', '操作系統(tǒng)','804'),
('6-166', '數(shù)字電路','856'),
('9-888', '高等數(shù)學(xué)','831')
(3)score
INSERT INTO score (sno,cno,degree) values
('103', '3-245','86'),
('105', '3-245','75'),
('109', '3-245','68'),
('103', '3-105','92'),
('105', '3-105','88'),
('109', '3-105','76'),
('101', '3-105','64'),
('107', '3-105','91'),
('108', '3-105','78'),
('101', '6-166','85'),
('107', '6-166','79'),
('108', '6-166','81')
(4)teacher
INSERT INTO teacher (tno,tname,tsex,tbirthday,prof,depart) values
('804', '李誠(chéng)','男','21521','副教授','計(jì)算機(jī)系'),
('856', '張旭','男','25274','講師','電子工程系'),
('825', '王萍','女','26424','助教','計(jì)算機(jī)系'),
('831', '劉冰','女','28351','助教','電子工程系')
新增數(shù)據(jù):
INSERT INTO score
SELECT 1,1,56 UNION ALL
SELECT 1,2,78 UNION ALL
SELECT 1,3,67 UNION ALL
SELECT 1,4,58 UNION ALL
SELECT 2,1,79 UNION ALL
SELECT 2,2,81 UNION ALL
SELECT 2,3,92 UNION ALL
SELECT 2,4,68 UNION ALL
SELECT 3,1,91 UNION ALL
SELECT 3,2,47 UNION ALL
SELECT 3,3,88 UNION ALL
SELECT 3,4,56 UNION ALL
SELECT 4,2,88 UNION ALL
SELECT 4,3,90 UNION ALL
SELECT 4,4,93 UNION ALL
SELECT 5,1,46 UNION ALL
SELECT 5,3,78 UNION ALL
SELECT 5,4,53 UNION ALL
SELECT 6,1,35 UNION ALL
SELECT 6,2,68 UNION ALL
SELECT 6,4,71
INSERT INTO course
SELECT 1,'語文',1 UNION ALL
SELECT 2,'數(shù)學(xué)',2 UNION ALL
SELECT 3,'英語',3 UNION ALL
SELECT 4,'物理',4
INSERT INTO teacher (sno,sname,ssex,sbirthday,class) VALUES
('1', '葉平', '男', NULL, NULL,'無'),
('2', '賀高', '男', NULL, NULL,'無'),
('3', '楊艷','女', NULL, NULL,'無'),
('4', '周磊','男', NULL, NULL,'無')
INSERT INTO student (sno,sname,ssex,sbirthday,class) VALUES
('1', '劉一','男', NULL,'無'),
('2', '錢二','女', NULL,'無'),
('3', '張三','男', NULL,'無'),
('4', '李四','女', NULL,'無'),
('5', '王五','男', NULL,'無'),
('6', '趙六','女', NULL,'無')