{"id":69,"date":"2026-08-30T21:04:47","date_gmt":"2026-08-30T13:04:47","guid":{"rendered":"https:\/\/www.233xianyu.top\/?p=69"},"modified":"2026-08-30T21:05:41","modified_gmt":"2026-08-30T13:05:41","slug":"3%e3%80%81%e8%a1%a8%e7%9a%84%e8%bf%9b%e9%98%b6%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/www.233xianyu.top\/index.php\/2026\/08\/30\/3%e3%80%81%e8%a1%a8%e7%9a%84%e8%bf%9b%e9%98%b6%e6%93%8d%e4%bd%9c\/","title":{"rendered":"03\u3001\u8868\u7684\u8fdb\u9636\u64cd\u4f5c"},"content":{"rendered":"<p><!-- wp:heading {\"level\":2} --><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_87 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.233xianyu.top\/index.php\/2026\/08\/30\/3%e3%80%81%e8%a1%a8%e7%9a%84%e8%bf%9b%e9%98%b6%e6%93%8d%e4%bd%9c\/#%E4%B8%80_%E4%BF%AE%E6%94%B9%E8%A1%A8%E7%9A%84%E6%93%8D%E4%BD%9C\" >\u4e00 \u4fee\u6539\u8868\u7684\u64cd\u4f5c<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.233xianyu.top\/index.php\/2026\/08\/30\/3%e3%80%81%e8%a1%a8%e7%9a%84%e8%bf%9b%e9%98%b6%e6%93%8d%e4%bd%9c\/#11_%E7%AE%80%E5%8D%95%E8%AF%AD%E6%B3%95\" >1.1 \u7b80\u5355\u8bed\u6cd5<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.233xianyu.top\/index.php\/2026\/08\/30\/3%e3%80%81%e8%a1%a8%e7%9a%84%e8%bf%9b%e9%98%b6%e6%93%8d%e4%bd%9c\/#%E4%BA%8C_%E8%AE%B0%E5%BD%95%E7%9A%84%E7%9B%B8%E5%85%B3%E6%93%8D%E4%BD%9C\" >\u4e8c \u8bb0\u5f55\u7684\u76f8\u5173\u64cd\u4f5c<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.233xianyu.top\/index.php\/2026\/08\/30\/3%e3%80%81%e8%a1%a8%e7%9a%84%e8%bf%9b%e9%98%b6%e6%93%8d%e4%bd%9c\/#21_%E8%AE%B0%E5%BD%95%E7%9A%84%E7%AE%80%E5%8D%95%E8%AF%AD%E6%B3%95\" >2.1 \u8bb0\u5f55\u7684\u7b80\u5355\u8bed\u6cd5<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.233xianyu.top\/index.php\/2026\/08\/30\/3%e3%80%81%e8%a1%a8%e7%9a%84%e8%bf%9b%e9%98%b6%e6%93%8d%e4%bd%9c\/#%E4%B8%89_%E5%8D%95%E8%A1%A8%E6%9F%A5%E8%AF%A2\" >\u4e09 \u5355\u8868\u67e5\u8be2<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.233xianyu.top\/index.php\/2026\/08\/30\/3%e3%80%81%e8%a1%a8%e7%9a%84%e8%bf%9b%e9%98%b6%e6%93%8d%e4%bd%9c\/#31_%E6%9F%A5%E8%AF%A2%E8%AF%AD%E6%B3%95\" >3.1 \u67e5\u8be2\u8bed\u6cd5<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E4%B8%80_%E4%BF%AE%E6%94%B9%E8%A1%A8%E7%9A%84%E6%93%8D%E4%BD%9C\"><\/span>\u4e00 \u4fee\u6539\u8868\u7684\u64cd\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3><span class=\"ez-toc-section\" id=\"11_%E7%AE%80%E5%8D%95%E8%AF%AD%E6%B3%95\"><\/span>1.1 \u7b80\u5355\u8bed\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code>1\u3001\u4fee\u6539\u8868\u540d\r\nalter table \u8868\u540d rename \u65b0\u8868\u540d\uff1b\r\n\r\n2\u3001\u589e\u52a0\u5b57\u6bb5\r\nalter table \u8868\u540d add \u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b[\u5b8c\u6574\u6027\u7ea6\u675f\u6761\u4ef6]\uff0c\u6570\u636e\u7c7b\u578b[\u5b8c\u6574\u6027\u7ea6\u675f\u6761\u4ef6]\uff1b\r\nalter table \u8868\u540d add \u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b[\u5b8c\u6574\u6027\u7ea6\u675f\u6761\u4ef6] first\uff1b\r\nalter table \u8868\u540d add \u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b[\u5b8c\u6574\u6027\u7ea6\u675f\u6761\u4ef6] after \u5b57\u6bb5\u540d\uff1b\r\n\r\n3\u3001\u5220\u9664\u5b57\u6bb5\r\nalter table \u8868\u540d drop \u5b57\u6bb5\u540d\uff1b\r\n\r\n4\u3001\u4fee\u6539\u5b57\u6bb5\r\nalter table \u8868\u540d modify \u5b57\u6bb5\u540d \u6570\u636e\u7c7b\u578b[\u5b8c\u6574\u6027\u7ea6\u675f\u6761\u4ef6]\uff1b\r\nalter table \u8868\u540d change \u65e7\u5b57\u6bb5\u540d \u65b0\u5b57\u6bb5\u540d \u65e7\u6570\u636e\u7c7b\u578b[\u5b8c\u6574\u6027\u7ea6\u675f\u6761\u4ef6]\uff1b\r\nalter table \u8868\u540d change \u65e7\u5b57\u6bb5\u540d \u65b0\u5b57\u6bb5\u540d \u65b0\u6570\u636e\u7c7b\u578b[\u5b8c\u6574\u6027\u7ea6\u675f\u6761\u4ef6]\uff1b\r\n\r\n5\u3001\u590d\u5236\u8868\r\ncreate table \u8868\u540d select \u5b57\u6bb51\u3001\u5b57\u6bb52 from \u88ab\u590d\u5236\u7684\u8868\u540d;\r\n# \u53ea\u590d\u5236\u8868\u7ed3\u6784\uff0c\u4e0d\u590d\u5236\u8868\u8bb0\u5f55\r\ncreate table \u8868\u540d select * from \u88ab\u590d\u5236\u7684\u8868\u540d where 1&gt;10;<\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n<p><!-- wp:heading {\"level\":2} --><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E4%BA%8C_%E8%AE%B0%E5%BD%95%E7%9A%84%E7%9B%B8%E5%85%B3%E6%93%8D%E4%BD%9C\"><\/span>\u4e8c \u8bb0\u5f55\u7684\u76f8\u5173\u64cd\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3><span class=\"ez-toc-section\" id=\"21_%E8%AE%B0%E5%BD%95%E7%9A%84%E7%AE%80%E5%8D%95%E8%AF%AD%E6%B3%95\"><\/span>2.1 \u8bb0\u5f55\u7684\u7b80\u5355\u8bed\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code>1\u3001\u63d2\u5165\u5b8c\u6574\u6570\u636e(\u987a\u5e8f\u63d2\u5165)\r\ninsert into \u8868\u540d(\u5b57\u6bb51\u3001\u5b57\u6bb52\u3001\u5b57\u6bb53...\u5b57\u6bb5n) values(\u503c1\uff0c\u503c2\uff0c\u503c3...\u503cn);\r\n# \u6309\u987a\u5e8f\u63d2\u5165\r\ninsert into \u8868\u540d values(\u503c1\uff0c\u503c2\uff0c\u503c3...\u503cn);\r\n# \u63d2\u5165\u591a\u6761\u8bb0\u5f55\r\ninsert into \u8868\u540d values\r\n(\u503c1\uff0c\u503c2\uff0c\u503c3...\u503cn)\uff0c\r\n(\u503c1\uff0c\u503c2\uff0c\u503c3...\u503cn)\uff0c\r\n(\u503c1\uff0c\u503c2\uff0c\u503c3...\u503cn)\uff1b\r\n\r\n2\u3001\u66f4\u65b0\u6570\u636e\r\nupdate \u8868\u540d set \u5b57\u6bb51=\u503c1\uff0c\u5b57\u6bb52=\u503c2\uff0cwhere condition\uff1b\r\n\r\n3\u3001\u5220\u9664\u6570\u636e\r\ndelete from \u8868\u540d where condition;<\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n<p><!-- wp:heading {\"level\":2} --><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E4%B8%89_%E5%8D%95%E8%A1%A8%E6%9F%A5%E8%AF%A2\"><\/span>\u4e09 \u5355\u8868\u67e5\u8be2<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:heading {\"level\":3} --><\/p>\n<h3><span class=\"ez-toc-section\" id=\"31_%E6%9F%A5%E8%AF%A2%E8%AF%AD%E6%B3%95\"><\/span>3.1 \u67e5\u8be2\u8bed\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><!-- \/wp:heading --><\/p>\n<p><!-- wp:code --><\/p>\n<pre class=\"wp-block-code\"><code>1\u3001\u67e5\u8be2\u67d0\u5b57\u6bb5\u7684\u79cd\u7c7b\u4e14\u4e0d\u91cd\u590d\r\nselect distinct \u5b57\u6bb51,\u5b57\u6bb52,... from \u5e93.\u8868\r\n                where \u8fc7\u6ee4\u6761\u4ef6\r\n                group by \u5206\u7ec4\u5b57\u6bb5\r\n                having \u8fc7\u6ee4\u6761\u4ef6\r\n                order by \u6392\u5e8f\u5b57\u6bb5\r\n                limit \u6761\u6570\r\n\r\n2\u3001\u7b80\u5355\u67e5\u8be2\r\nselect distinct \u5b57\u6bb51,\u5b57\u6bb52,... from \u5e93.\u8868;\r\n\r\n3\u3001\u6761\u4ef6\u67e5\u8be2\r\nselect id\uff0c(\r\ncase \r\nwhen name='egon' then concat(name,\"_vip\")\r\nwhen name='alex' then concat(name,\"_bigsb\")\r\nelse\r\nname\r\nend\r\n) as new_name from employee;\r\n\r\n3\u3001where\u5b50\u53e5\u8fdb\u884c\u7b5b\u9009\r\nselect * from employee where id=3;\r\nselect * from employee where id&gt;=3;\r\nselect * from employee where id!=3;\r\n\r\nselect * from employee where id&gt;3 and id&lt;5;\r\nselect * from employee where id&lt;3 or id&gt;10;\r\nselect * from employee where id&gt;=3 and id&lt;=5;\r\n\r\nselect * from employee where id=3 or id=5 or id=7;\r\nselect * from employee where id in (3,5,7);\r\n\r\n# \u6a21\u7cca\u5339\u914d\r\n# ji\u5f00\u5934\u7684\u540e\u9762\u65e0\u9650\u4f4d    \r\nselect * from employee where name like 'ji%';\r\n# ji\u5f00\u5934\u7684\uff0c\u540e\u9762\u8ddf\u4e00\u4f4d\r\nselect * from employee where name like 'ji_';\r\n# \u53ea\u8981\u662f\u4e24\u4f4d\u7684\u90fd\u88ab\u5339\u914d\u5230\r\nselect * from employee where name like '__';\r\n# \u6b63\u5219\u5339\u914d\r\n# \u4ee5jin\u5f00\u5934\u7684\r\nselect * from employee where name regexp '^jin';\r\n# \u4ee5n\u7ed3\u5c3e\u7684 \r\nselect * from employee where name regexp 'n$';\r\n\r\n<\/code><\/pre>\n<p><!-- \/wp:code --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00 \u4fee\u6539\u8868\u7684\u64cd\u4f5c 1.1 \u7b80\u5355\u8bed\u6cd5 \u4e8c \u8bb0\u5f55\u7684\u76f8\u5173\u64cd\u4f5c 2.1 \u8bb0\u5f55\u7684\u7b80\u5355\u8bed\u6cd5 \u4e09 \u5355\u8868\u67e5\u8be2 3.1 \u67e5\u8be2\u8bed\u6cd5<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-69","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/posts\/69","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":2,"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"predecessor-version":[{"id":74,"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/posts\/69\/revisions\/74"}],"wp:attachment":[{"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.233xianyu.top\/index.php\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}