4.DDL-表操作-查询
①查询当前数据库所有表
show tables;
②查询表结构
desc 表名;
③查询指定表的建表语句
show create table 表名;
5.DDL-表操作-创建
①创建表语法
create table 表名(
字段1 字段1类型 [comment 字段1注释],
字段2 字段2类型 [comment 字段2注释],
字段3 字段3类型 [comment 字段3注释],
...
字段n 字段n类型 [comment 字段n注释]
) [comment 表注释];
注意:字段n最后没有“,”
例子:
id | name | age | gender |
1 | 喜羊羊 | 28 | 男 |
2 | 懒羊羊 | 24 | 男 |
create table tb_user(
id int comment '编号',
name varchar(50) comment '姓名',
age int comment '年龄',
gender varchar(1) comment '性别'
) comment '用户表';