{"id":911,"date":"2022-03-19T21:56:36","date_gmt":"2022-03-19T13:56:36","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=911"},"modified":"2022-03-19T21:56:38","modified_gmt":"2022-03-19T13:56:38","slug":"5-sql%e8%af%ad%e5%8f%a5%e4%b9%8bdcl%e6%95%b0%e6%8d%ae%e6%8e%a7%e5%88%b6%e8%af%ad%e8%a8%80%e5%92%8cdml%e6%95%b0%e6%8d%ae%e6%93%8d%e4%bd%9c%e8%af%ad%e8%a8%80","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=911","title":{"rendered":"5.SQL\u8bed\u53e5\u4e4bDCL\u6570\u636e\u63a7\u5236\u8bed\u8a00\u548cDML\u6570\u636e\u64cd\u4f5c\u8bed\u8a00"},"content":{"rendered":"\n<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.DCL\u6570\u636e\u63a7\u5236\u8bed\u8a00<\/h2>\n\n\n\n<p>grant\u3001revork\u5177\u4f53\u7684\u53ef\u4ee5\u53c2\u8003\u57fa\u7840\u7ba1\u7406\u7684\u6743\u9650\u7ba1\u7406\u90e8\u5206<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">2.DML\u6570\u636e\u64cd\u4f5c\u8bed\u8a00<\/h2>\n\n\n\n<p><strong><em>1.\u4f5c\u7528<\/em><\/strong><\/p>\n\n\n\n<p>\u5bf9\u8868\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u589e\u5220\u6539\u67e5<\/p>\n\n\n\n<p><strong><em>2.\u5411\u8868\u4e2d\u63d2\u5165\u6570\u636einsert<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>###\u5168\u90e8\u5217\u90fd\u63d2\u5165\u6570\u636e\r\nmysql> insert into test.stu (id,stusname,age,gender,telnu,addr) values (2,'\u5f20\u4e09',18,'M','110','bj');\r\n###\u5168\u90e8\u5217\u90fd\u63d2\u5165\u6570\u636e\u53ef\u4ee5\u7701\u7565\u5217\u540d\r\nmysql> insert into test.stu values (3,'\u5f20\u4e09',18,'M','110','bj');\r\n###\u63d2\u5165\u591a\u5217\r\nmysql> insert into test.stu values (4,'\u5f20\u4e09',18,'M','110','bj'), (5,'\u674e\u56db',18,'M','110','bj');\r\n###\u5411\u67d0\u4e00\u5217\u63d2\u5165\u6570\u636e\r\nmysql> insert into test.stu (id,stusname,addr) values (2,'\u5f20\u4e09', 'bj');\r\n#\u67e5\u8be2\u8868\u4e2d\u6240\u6709\u6570\u636e\r\nmysql> select * from test.stu;\r<\/code><\/pre>\n\n\n\n<p><strong><em>3.\u66f4\u65b0\u8868\u4e2d\u6570\u636eupdate<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u4fee\u6539\u8868\u4e2d\u7684\u5185\u5bb9\uff0c\u4fee\u6539stusname\u5217\u7684\u503c\u4e3azaa \u5728id=6\u7684\u884c\r\nmysql> update test.stu set stusname='zaa' where id='6';\r\n#\u5982\u679c\u4e0d\u52a0where\u7684\u8bdd\uff0c\u6240\u6709stusname\u7684\u5217\u90fd\u4f1a\u66ff\u6362\u4e3azaa\uff0c\u6240\u4ee5\u53ef\u4ee5\u5f00\u542f\u5b89\u5168\u6a21\u5f0f\r\n#\u67e5\u8be2\u5b89\u5168\u6a21\u5f0f\r\nmysql> show variables like '%safe%';\r\n#\u8bbe\u7f6e\u4e3a\u5f00\u542f\r\nmysql> set global sql_safe_updates=1;\n#\u8bbe\u7f6e\u662f\u6c38\u4e45\u751f\u6548\u7684\uff0c\u4f46\u662f\u9700\u8981\u65ad\u5f00\u91cd\u8fde\u624d\u751f\u6548\r\n#\u5f53\u7136\u53ef\u4ee5\u5c06\u53c2\u6570\u5199\u5165mysql\u7684\u914d\u7f6e\u6587\u4ef6\u91cc\r\n\r<\/code><\/pre>\n\n\n\n<p><strong><em>4.\u5220\u9664\u8868\u4e2d\u6570\u636edelete<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql> delete from test.stu where id='6';<\/code><\/pre>\n\n\n\n<p><strong><em>5.\u5f69\u86cb\uff08\u4f2a\u5220\u9664\uff09<\/em><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a.\u6570\u636e\u4e0d\u8981\u4e86\uff0c\u5220\u9664\u6709\u98ce\u9669\uff0c\u5e94\u8be5\u600e\u4e48\u505a\r\n\u589e\u52a0\u4e00\u4e2a\u72b6\u6001\u5217\uff0c\u6709\u7528\u7684\u6570\u636e\u72b6\u6001\u8bbe\u7f6e\u4e3a0\uff0c\u65e0\u7528\u7684\u6570\u636e\u72b6\u6001\u8bbe\u7f6e\u4e3a1\r\nmysql> alter table test.stu add stats tinyint not null default 0 comment '0\u4e3a\u6709\u7528\u6570\u636e\uff0c1\u4e3a\u65e0\u7528\u6570\u636e';\r\n\u67e5\u8be2\u6709\u7528\u7684\u6570\u636e\u52a0\u4e00\u4e2awhere stats=0\r\nmysql> select * from test.stu where stats=0;\r<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/911"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=911"}],"version-history":[{"count":1,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/911\/revisions"}],"predecessor-version":[{"id":912,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/911\/revisions\/912"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}