1.查看数据表
语法格式:
show tables;
运行结果:初始时表为空
2.创建数据表
语法格式:
create table 表名 (字段名 数据类型,);
以表名为student,字段名为id和name为例,运行结果:
3.查看表的创建语句
语法格式:
show create table 表名;
运行结果:
4.查看表结构
语法格式:
desc 表名;
运行结果:
5.修改表名
语法格式:
rename table 旧表名 to 新表名;
运行结果,以students改为plays为例:
6.增加数据表字段
语法格式:
create table student(字段名 字段类型 是否为空 主键 约束条件
);
运行结果:
7.修改数据表字段
语法格式:
update 表名 set 字段1=值1,字段2=值2 where 条件;
运行结果:
8.删除数据表字段
语法格式:
delete from 表名 where 条件;
运行结果:
9.删除数据表
语法格式:
truncate table 表名;
运行结果