- 查看當前數據庫中所有表
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 數據庫中對錶的操作命令(不建議修改表結構)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.