#1.创建数据库test01_office,指明字符集为utf8。并在此数据库下执行下述操作
create database if not exists test01_office character set 'utf8';
#2.创建表dept81
/*
字段 类型
id INT(7)
NAME VARCHAR(25)
类型
*/
use test01_office;
create table if not exists dept01(
id INT(7),
NAME VARCHAR(25)
);
#3.将表departments中的数据插入新表dept02中
create table if not exists dept02 as
select * from atguigudb.departments
#4 .创建表emp01
/*
字段 类型
id INT(7)
first_name VARCHAR(25)
last_name VARCHAR(25)
dept_id INT(7)
*/
create table if not exists emp01(
id INT(7),
first_name VARCHAR(25),
last_name VARCHAR(25),
dept_id INT(7)
);
#5.将列last_name的长度增加到50
alter table emp01 modify last_name VARCHAR(50);
desc emp01;
#6。根据表employees创建emp02
create table emp02 as
select * from atguigudb.employees;
#7.删除表emp01
drop table emp01;
#8.将表emp02重命名为emp01
rename table emp02 to emp01;
#9.在表dept02和emp01中添加新列test_column,并检查所作的操作
alter table dept02 add test_column VARCHAR(10);
alter table emp01 add test_column VARCHAR(10);
#10.直接删除表emp01中的列 dept_id
desc emp01;
alter table emp01 drop dept_id;
标签:10,emp01,VARCHAR,name,25,创建,课后练习,table,id
From: https://www.cnblogs.com/ratillase/p/18220124