Do you know that the mysql command line tool has --i-am-a-dummy option? It's an option for beginners that has the same effect as --safe-updates. The --i-am-a-dummy option is very helpful because it prevents accidents. If you execute the SQL statement:
what happens? You delete all rows from the table. With the --i-am-a-dummy option:
- You cannot delete or update rows without specifying the key values that identify them or providing a LIMIT clause
- All large select are automatically limited to 1,000 rows unless the statement includes a LIMIT clause.
- Multiple-table SELECT statements that probably need to examine more than 1,000,000 row combinations are aborted.
Example:
Replace the user_name and user_password with your MySQL user name and passord
DELETE FROM table_namewhat happens? You delete all rows from the table. With the --i-am-a-dummy option:
- You cannot delete or update rows without specifying the key values that identify them or providing a LIMIT clause
- All large select are automatically limited to 1,000 rows unless the statement includes a LIMIT clause.
- Multiple-table SELECT statements that probably need to examine more than 1,000,000 row combinations are aborted.
Example:
mysql --i-am-a-dummy -uuser_name -puser_passwordReplace the user_name and user_password with your MySQL user name and passord
mysql> delete from table_name;
ERROR 1175: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column