进入MySQL
mysql -u root -p

(1)创建数据库stuexpm
CREATE DATABASE stuexpm;

(2)创建StudentInfo表,显示StudentInfo表的基本结构
USE stuexpm;

CREATE TABLE StudentInfo
CREATE TABLE StudentInfo
-> (
-> StudentID varchar(6) not null primary key,
-> Name varchar(8) not null,
-> Sex varchar(2) not null default'男',
-> Birthday date not null,
-> Speciality Varchar(12) null,
-> Address varchar(20) null
-> );

(3)由StudentInfo表使用复制方式创建StudentInfo表

(4)在StudentInf表中增加一列StuNo,添加到表的第一列,不为空,取值唯一并自动增加,显示StudentInfo表的基本结构
alter table StudentInfo
-> add column StuNo int not null unique auto_increment first;
desc StudentInfo;

(5)将StudentInfo1表的Address列修改为City,将数据类型改为插入,可为空,默认值为北京,显示StudentInfo表的基本结构
alter table StudentInfo1
-> change column Address City char(4) null default'北京';

(6)将StudentInfo1表的Speciality列修改为school,将数据库类型改为char ,可以为空,默认值为“计算机学院”。
alter table StudentInfo1
-> change column Speciality School char(10) null default'计算机学院';

(7)将StudentInfo1表的默认值修改为上海
alter table StudentInfo1
-> alter column City set default'上海';

(8)将StudentInfo1表中的City列的类型修改为varchar(20),并移入到Name之后。
alter table StudentInfo1
-> modify column City varchar(20) after Name;

(9)在StudentInfo1表中删除StuNO列。

(忘在表中添加StuNO列,后补充)
(10)将StudentInfo1表更名为StudentInfo2表。
alter table StudentInfo1
-> rename to StudentInfo2;

(11)删除StudentInfo2
drop table StudentInfo2;
