Mysql second experiment []

use chapter02;


create table Student (
Sno int not null comment '学生编号',
Sname varchar(20) not null comment '学生名称',
Sgender varchar(5) not null comment '学生性别',
SBirthday datetime comment'学生生日',
class varchar(20) comment '所属班级'
);

create table Course (
Cno int not null comment '课程编号',
Cname varchar(20) not null comment '课程名称',
Tno varchar(5) not null comment '教工编号'
);

# 三
create table Score (
Sno int not null comment '学号',
Cnno varchar(20) not null comment '课程好',
grade varchar(5) not null comment '成绩'
);


create table Teacher (
Tno int not null comment '教工编号',
Tname varchar(20) not null comment '教工名称',
Tgender varchar(5) not null comment '教工性别',
TBirthday datetime comment'教工生日',
Prof varchar(20) comment '职称'
);

alter table chapter02 rename stu_table;

#6、查看数据表 stu_table 结构
desc stu_table;

#7、修改表 Teacher 中字段 Tsex 为 Tgender
alter table Teacher change `teacher` Tgender varchar;

#8、在表 Teacher 中添加字段 depart,其含义为部门
alter table Teacher add  column depart varchar(10);

#9、修改表 Teacher 中职称字段排列位置到姓名后
alter table Teacher modify Prof varchar(10) firstafter Tname; 

#10、删除表 Teacher 中性别字段
alter table Teacher drop column Tgender;

#11、删除数据表 Teacher
drop table Teacher;

show variables like "%char%";
Published 495 original articles · won praise 105 · views 30000 +

Guess you like

Origin blog.csdn.net/qq_43539599/article/details/104797208