September 10, 2004

MySQL | --i-am-a-dummy

I thought it was a joke when I first heard about it, but the MySQL command line client has this option where you can actually tell it you're stupid:

 mysql --i-am-a-dummy -uroot test

Otherwise known as --safe-updates, this option prevents MySQL from performing update operations unless a key constraint in the WHERE clause and / or a LIMIT clause are provided, e.g.:

mysql> DELETE FROM bigtable;
ERROR 1175: You are using safe update mode and you
tried to update a table without a WHERE that uses a 
KEY column

This would wipe out bigtable - unless bigtable is an InnoDB table and the command is wrapped in a transaction. (If you don't use transactions, you should have a lot more to worry about anyway).

See: http://dev.mysql.com/doc/mysql/en/safe-updates.html.

Note that the --safe-updates / --i-am-a-dummy option causes the following statement to be issued on connection:


Posted at 9:09 PM