Knowledge Walls
John Peter
Pune, Maharashtra, India
How to drop all constraints in Mysql? in Cool Topics of MySQL
4573 Views
Five Steps to Drop all constrains in Mysql 
1. Copy to another table.
2. Set foreign_key_checks false.
3. Remove existing table.
4. Set back foreign_key_check true.
5. Do rename of copy table.
Example
-- [copy_table_name] is any name
-- [table_name] which table do you want to remove all constraints

CREATE TABLE [copy_table_name] (SELECT * FROM [table_name]);
SET foreign_key_checks = 0;
DROP TABLE [table_name];
SET foreign_key_checks = 1;
ALTER TABLE [copy_table_name] RENAME [table_name];
Previous Topics
Previous lessons of current book.
INFORMATION_SCHEMA Db of MySQL
INFORMATION_SCHEMA Db of MySQL
INFORMATION_SCHEMA Db of MySQL
Best Lessons of "MySQL"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details