1、create database china;

创建数据库


2、show databases;

查看当前实例所拥有的数据库


3、use china;

选择(使用)数据库


4、create table t1( id int not null auto_increment, name char(10), city char(10), country char(10), email char(20),primary key (`id`)) engine=Innodb charset=utf8;

建表


5、show tables;

查看当前库所拥有的表


6、desc t1;

获取数据表结构


7、show create table t1;

查看建表语句


8、show status;

显示当前mysql实例的运行状态


9、status;

显示当前库的状态


10、alter table t1 add address char(40);

增加字段


11、alter table t1 drop address;

删除字段


12、create table t3 like t1;

复制表(只包含表结构)


13、alter table t1 modify city char(30);

更改类型


14、alter table t1 rename t2;

表的重命名


15、alter table t2 convert to charset gbk;

更改字符集


16、alter table t2 change city sex char(40);

更改字段名


17、alter table t3 add primary key(id);

增加主键