#课本P78实验4.2-3
#(2)创建studentinfo表,显示studentinfo表的基本结构
show databases;
use stuexpm;
desc studentinfo;
show create table studentinfo;
#(3)由studentinfo表使用复制方式创建studentinfo1表
use stuexpm;
create table studentinfo1 like studentinfo;
#(4)在studentinfo1表中增加一列stuno,添加到表的第1列,不为空,取值唯一并自动增加,显示studentinfo表的基本结构
alter table studentinfo1
add column StuNo int not null unique auto_increment first;
desc studentinfo1;
#(5)将studentinfo1表的address 列修改 为city ,将数据类型改为char,可为空,默认值为"北京",显示studentinfo1表的基本结构
alter table studentinfo1
change column address city char(20) null default '北京';
desc studentinfo1;
desc studentinfo;
#(6)将studentinfo1表的speciality 列修改为school,将数据类型改为char,可为空,默认值为"计算机学院"
alter table studentinfo1
change column speciality school char(20) null default '计算机学院';
desc studentinfo1;
#(7)将studentinfo1表的city列的默认值修改为"上海"
alter table studentinfo1
alter column city set default '上海';
desc studentinfo1;
#(8)将studentinfo1表的city列的类型修改为varchar(20),并移到列Name之后
alter table studentinfo1
modify city varchar(20) after Name;
desc studentinfo1;
#(9)在studentinfo1表中删除stuno列
alter table studentinfo1
drop column stuno;
#(10)将studentinfo1表更名为studentinfo2表
alter table studentinfo1
rename to studentinfo2;
#(11)删除studentinfo2表
drop table studentinfo2;