2、查看该库下几个表以及查看两张表结构
/查看company数据库下的表/
SHOW TABLES FROM company;
/查看company数据库的表结构/
DESC offices;
DESC employees;
3、将表employees的mobile字段修改到officeCode字段后面
/将表employees的mobile字段修改到officeCode字段后面/
ALTER TABLE employees MODIFY mobile VARCHAR(25) AFTER officeCode;
4、将表emplouees的birth字段改名为employee_birth
/将表emplouees的birth字段改名为employee_birth/
ALTER TABLE employees CHANGE birth employee_birth DATETIME;
5、修改sex字段,数据类型为CHAR(1),非空约束
/修改sex字段,数据类型为CHAR(1),非空约束/
ALTER TABLE employees MODIFY sex CHAR(1) NOT NULL;
6、/删除字段note/
/删除字段note/
ALTER TABLE employees DROP note;
7、增加字段名favoriate_activity,数据类型为VARCHAR(100)
/增加字段名favoriate_activity,数据类型为VARCHAR(100)/;
ALTER TABLE employees ADD favoriate_activity VARCHAR(100);
8、删除表offices
/删除表offices/
ALTER TABLE employees DROP FOREIGN KEY officeCode_pid; #将外键删除,否则无法删除此表#
DROP TABLE offices;
9、将表employees名称改为employess_info
/将表employees名称改为employess_info/
RENAME TABLE employees TO employees_info;
03-14
115
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-05
10-21
277
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)