MySQL数据表的基本操作二:表结构查看、修改与表操作(二)

2014-11-24 13:53:16 · 作者: · 浏览: 1
, 0 rows affected (0.07 sec) mysql> create table employee -> ( -> id int(11) primary key, -> name varchar(25), -> department_id int(11), -> salary float, -> constraint fk_emp_dept foreign key(department_id) references department(id) -> ); Query OK, 0 rows affected (0.10 sec) mysql> drop table department; ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails mysql> alter table employee drop foreign key fk_emp_dept; Query OK, 0 rows affected (0.22 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql>
drop table department; Query OK, 0 rows affected (0.04 sec) mysql> show tables; +------------------+ | Tables_in_rm_tab | +------------------+ | employee | +------------------+ 1 row in set (0.00 sec)

如果您们在尝试的过程中遇到什么问题或者我的代码有错误的地方,请给予指正,非常感谢!

联系方式:david.louis.tian@outlook.com

版权@:转载请标明出处!