- 查看当前数据库中所有表
show tables;
- 创建表
格式:create table 表名(列以及类型)
示例:create table student1(id int auto_increment primary key , name varchar(20) not null , age int not null , gender bit default 1 , address varchar(20) , isDelete bit default 0);
说明:auto_increment 表示自增
primary key 主键
not null 不为空
- 删除表
格式:drop table 表名;
示例: drop table car;
- 查看表结构
格式:desc 表名;
示例:desc student;
- 查看建表语句
格式:show create table 表名;
示例:show create table student1 ;
- 重命名表名
格式:rename table 原表名 to 新表名
示例:rename table student1 to newstudent;
- 修改表结构(不建议修改表结构)
格式:alter table 表名 add | change | drop 列名 类型;
示例:alter table newstudent add school varchar(20 ) not null;
【mysql 数据库】05 数据库中对表的操作命令(不建议修改表结构)
猜你喜欢
转载自blog.csdn.net/weixin_38114487/article/details/105377358
今日推荐
周排行