MySql教程:MySQL创建学生表 课程表 成绩表 基础教程开始。
创建数据库
create database student
创建学生表
create table student
(
stu_name varchar(30) not null,
stu_id char primary key (stu_id),
stu_specialty varchar(30) not null,
stu_sex char(2) check( stu_sex in (‘男’,’女’)),
stu_age int check (stu_age>16)
)
创建课程表
create table studentclass
(
stu_classid varchar(30) not null,
stu_id char not null primary key (stu_id),
stu_classname varchar(30) not null,
stu_age int check (stu_age>16),
stu_time datetime not null
)
创建成绩表
create table studentscore
(
stu_id char primary key (stu_id),
stu_classid varchar(30) not null,
stu_score int not null
)
查询学生表
select *from student
插入学生表数据
insert into student values (‘张三’,’01’,’计算机专业’,’男’,’10’)
insert into student values (‘张四’,’02’,’计算机专业’,’男’,’11’)
insert into student values (‘王五’,’03’,’计算机专业’,’男’,’12’)
插入课程表数据
insert into studentclass values(‘001’,’java’,’2’,’40’)
insert into studentclass values(‘001’,’c’,’2’,’41’)
insert into studentclass values(‘001’,c++’,’2’,’42’)
插入成绩表数据
insert into studentscore values(‘01’,’001’,’60’)
insert into studentscore values(‘01’,’002’,’70’)
insert into studentscore values(‘01’,’003’,’80’)
MySql教程:MySQL创建学生表 课程表 成绩表 结束。
更多文章,请持续关注《MySql教程网》https://mysql360.com