1.sql_safe_updates官方解釋如下:If set to 1, MySQL aborts UPDATE or DELETE statements that do not use a key in the WHERE clause or a LIMIT clause. (Specifica...
1. sql_safe_updates
官方解釋如下:
If set to 1, MySQL aborts UPDATE or DELETE statements that do not use a key in the WHERE clause or a LIMIT clause. (Specifically, UPDATE statements must have a WHERE clause that uses a key or a LIMIT clause, or both. DELETE statements must have both.) This makes it possible to catch UPDATE or DELETE statements where keys are not used properly and that would probably change or delete a large number of rows. The default value is 0.
預設為0,如果設置為1,則delete操作和update操作必須帶有where子句,且where子句中的列必須是key或primary key,如果表設計的時候本來就沒有設置key或primary key,則delete和update操作將不被允許,如果表設計的時候設置了key或者primary key,但where指定的是其它列,delete和update操作同樣不被允許。