1.修改表结构
alter table 表名字 add 列名 类型;
mysql> alter table students add birthday datetime;
Query OK, 0 rows affected (0.00 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> desc students;
+----------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(20) | NO | | NULL | |
| age | tinyint(1) | YES | | NULL | |
| high | decimal(3,2) | YES | | NULL | |
| gender | enum('man','woman') | YES | | NULL | |
| cls_id | int(10) unsigned | YES | | NULL | |
| birthday | datetime | YES | | NULL | |
+----------+---------------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)
2.修改字段名字 -- 重新命名
alter table 表名 change 字段名 新字段名;
3.修改字段类型
mysql> alter table students modify brith date not null;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
3.删除字段
alter table 表名 drop 字段名;
2.删除表
drop table 表名;