MySQL--數據表操作
阿新 • • 發佈:2017-09-07
mysql--數據表操作
| 表的創建 create table 表名(字段名 類型名 約束) # create table students( id int unsigned primary key auto_increment not null, name varchar(20) default ‘‘, age tinyint unsigned default 0, height decimal(5,2), gender enum(‘男‘,‘女‘,‘人妖‘,‘保密‘), cls_id int unsigned default 0 ); # create table classes( id int unsigned auto_increment primary key not null, name varchar(10) ); | 查看數據庫中所有表 show tables; | 查看創建語句 show create table classes; | 查看表結構,描述表 desc classes; - 修改字段 | 修改表-添加字段 add alter table students add birthday datetime; | 修改表-修改字段:不重命名版 modify alter table students modify birthday date; | 修改表-修改字段:重命名版 change alter table students change birthday birth date; | 修改表-刪除字段 drop alter table students drop high; | 刪除表 drop table students;
MySQL--數據表操作