第二章MySQL 的基本操作
202212046203238 祝文欢 计网2班
实验目的:
Mysql 创建 数据库 、数据表、修改数据表
任务一:新建数据库school,使用数据库
create database school;
任务二:新建教师表格(id int comment'工号',name varchar(20) comment'姓名',gender char(1) comment'性别');
create table if not exists teacher(
id int comment'工号',
name varchar(20) comment'姓名',
gender char(1) comment'性别');
任务三:掌握修改数据表的六种方法
-
改表名-tch;
alter table teacher rename tch;
-
改字段名: id为tchno
alter table tch rename column id to tchno;
-
改字段的数据类型:name 为char(20);
alter table tch modify name char(20);
-
添加字段:birthday char(20) comment'生日' 放在name 后面;
alter table tch add birthday char(20) comment'生日' after name;
-
修改字段的位置:name放第一;
Alter table tch modify name char(20) first;
-
删除字段gender;
alter table tch drop gender;