In order to insert value 0 in a field that is set as primary key for a MySQL table you need to execute the following query prior to any insert query:
SET SESSION SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
Now you can successfully run the insert query with 0 set as value for a primary key, without getting any error message.
Mentioning the “SESSION” variable will make sure that you do not change the sql mode globally, but if you really want to change it globally you need to execute:
SET GLOBAL SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
Disabling foreign key checks in MySQL is usefull when you are dealing with tables that use foreign keys (InnoDB engine).
You can not delete (drop) multiple tables, a parent table or a child table until you disable foreign key checks four your current database.
The sql command to disable foreign key checks is:
SET FOREIGN_KEY_CHECKS = 0;
To enable the foreign key checks use the opposite command:
SET FOREIGN_KEY_CHECKS = 1;