1. 查看当前选择的数据库
show tables;(若此数据库中无表,则显示:Empty set)
2. 创建表
格式: create table 表名(列及类型);
说明:auto_increment 表明自增长 primary key 主键 not null 表示不为空
示例一: create table student(id int auto_increment primary key);
示例二:create table student(id int auto_increment primary key, name varchar(20) not null, age int not null, gender bit default 1, address varchar(20));
3. 查看表中数据属性
格式:show columns from 表名;
示例: show columns from student;
3. 删除表
格式:drop table 表名;
示例:drop table student;
4. 查看表中数据的属性
格式:desc 表名;
示例:desc student;
5. 查看建表语句
格式: show create table 表名;
示例: show create table student;
6. 重命名表名
格式: rename table 原表名 to 新表名;
示例:rename table student to students;
7. 修改表
格式: alter table 表名 add|change|drop 列名 类型;
示例: alter table students add isDelete bit default 0;
显示表的结构: