91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL中怎么防止無where條件的update操作

發布時間:2021-07-21 11:41:34 來源:億速云 閱讀:202 作者:Leah 欄目:MySQL數據庫

本篇文章為大家展示了MySQL中怎么防止無where條件的update操作,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。


1、加-U登錄數據庫

點擊(此處)折疊或打開

  1. [root@master ~]# mysql -uroot -pmysql -U

  2. mysql: [Warning] Using a password on the command line interface can be insecure.

  3. Welcome to the MySQL monitor. Commands end with ; or \g.

  4. Your MySQL connection id is 12

  5. Server version: 5.7.19-log Source distribution


  6. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.


  7. Oracle is a registered trademark of Oracle Corporation and/or its

  8. affiliates. Other names may be trademarks of their respective

  9. owners.


  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


  11. mysql>

  12. mysql> use test;

  13. Reading table information for completion of table and column names

  14. You can turn off this feature to get a quicker startup with -A


  15. Database changed

  16. mysql> show tables;

  17. +----------------+

  18. | Tables_in_test |

  19. +----------------+

  20. | t1 |

  21. +----------------+

  22. 1 row in set (0.00 sec)


  23. mysql> show create table t1;

  24. +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

  25. | Table | Create Table |

  26. +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

  27. | t1 | CREATE TABLE `t1` (

  28.   `admin_id` int(11) NOT NULL DEFAULT '0',

  29.   `admin_name` varchar(200) NOT NULL,

  30.   `password` varchar(200) NOT NULL,

  31.   `role` int(11) NOT NULL DEFAULT '1',

  32.   `last_login_time` datetime DEFAULT NULL,

  33.   `last_login_ip` varchar(16) DEFAULT '',

  34.   `admin_status` int(11) NOT NULL DEFAULT '1',

  35.   `create_time` datetime DEFAULT NULL

  36. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 |

  37. +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

  38. 1 row in set (0.00 sec)


  39. mysql> update t1 set admin_status=1234;

  40. ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

此處可以看到數據庫給出了提示,不允許沒有where條件的update操作。
2、根據這樣的特性,對系統環境變量進行更改
vi /etc/profile
alias mysql='mysql -U'
source /etc/profile
3、正常命令登錄MySQL,進行測試

點擊(此處)折疊或打開

  1. [root@master ~]# mysql -uroot -pmysql

  2. mysql: [Warning] Using a password on the command line interface can be insecure.

  3. Welcome to the MySQL monitor. Commands end with ; or \g.

  4. Your MySQL connection id is 14

  5. Server version: 5.7.19-log Source distribution


  6. Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.


  7. Oracle is a registered trademark of Oracle Corporation and/or its

  8. affiliates. Other names may be trademarks of their respective

  9. owners.


  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


  11. mysql> use test;

  12. Reading table information for completion of table and column names

  13. You can turn off this feature to get a quicker startup with -A


  14. Database changed

  15. mysql> update t1 set admin_status=1234;

  16. ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

上述內容就是MySQL中怎么防止無where條件的update操作,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

清新县| 唐海县| 廊坊市| 调兵山市| 定陶县| 宿迁市| 嵊泗县| 南投市| 张家川| 岗巴县| 横峰县| 镇宁| 云霄县| 淳化县| 普陀区| 金溪县| 石家庄市| 辽源市| 南岸区| 盐池县| 苍梧县| 宁乡县| 弥勒县| 康马县| 北碚区| 上思县| 福鼎市| 枞阳县| 名山县| 伊春市| 辽阳市| 稷山县| 凌海市| 聂荣县| 新源县| 安乡县| 突泉县| 海晏县| 靖安县| 磐石市| 曲松县|