{"id":636,"date":"2024-11-25T22:13:38","date_gmt":"2024-11-25T14:13:38","guid":{"rendered":"http:\/\/www.chan.ink\/?p=636"},"modified":"2024-11-26T01:33:28","modified_gmt":"2024-11-25T17:33:28","slug":"%e3%80%90mysql%e3%80%91%e7%b4%a2%e5%bc%95","status":"publish","type":"post","link":"http:\/\/www.chan.ink\/index.php\/2024\/11\/25\/%e3%80%90mysql%e3%80%91%e7%b4%a2%e5%bc%95\/","title":{"rendered":"\u3010MySQL\u3011\u7d22\u5f15"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u7d22\u5f15\u539f\u7406\uff1a\u5e95\u5c42\u662f\u56e0\u4e3a\u57fa\u4e8eB+Tree\u7684\u6570\u636e\u7ed3\u6784\u5b58\u50a8<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u521b\u5efa\u6570\u636e\u5e93\u8868\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u6307\u5b9a\u4e0d\u540c\u7684\u5f15\u64ce\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>myisam\u5f15\u64ce\uff0c\u975e\u805a\u7c07\u7d22\u5f15\uff08\u6570\u636e \u548c \u7d22\u5f15\u7ed3\u6784 \u5206\u5f00\u5b58\u50a8\uff09<\/li>\n\n\n\n<li>innodb\u5f15\u64ce\uff0c\u805a\u7c07\u7d22\u5f15\uff08\u6570\u636e \u548c \u4e3b\u952e\u7d22\u5f15\u7ed3\u6784\u5b58\u50a8\u5728\u4e00\u8d77\uff09<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><app-translate-content class=\"eusoft-translate-container-span-en ng-star-inserted\" _nghost-ng-c341168634=\"\"><span _ngcontent-ng-c341168634=\"\" class=\"eusoft-eudic-chrome-extension-translate-content\"><\/span><\/app-translate-content><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e38\u89c1\u7d22\u5f15<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e3b\u952e\u7d22\u5f15\uff1a\u52a0\u901f\u67e5\u627e\u3001\u4e0d\u80fd\u4e3a\u7a7a\u3001\u4e0d\u80fd\u91cd\u590d\u3002 + \u8054\u5408\u4e3b\u952e\u7d22\u5f15<\/li>\n\n\n\n<li>\u552f\u4e00\u7d22\u5f15\uff1a\u52a0\u901f\u67e5\u627e\u3001\u4e0d\u80fd\u91cd\u590d\u3002 + \u8054\u5408\u552f\u4e00\u7d22\u5f15<\/li>\n\n\n\n<li>\u666e\u901a\u7d22\u5f15\uff1a\u52a0\u901f\u67e5\u627e\u3002 + \u8054\u5408\u7d22\u5f15<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f1a\u6709\u4e00\u4e9b\u7279\u6b8a\u7684\u60c5\u51b5\uff0c\u8ba9\u6211\u4eec\u65e0\u6cd5\u547d\u4e2d\u7d22\u5f15\uff08\u5373\u4f7f\u521b\u5efa\u4e86\u7d22\u5f15\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>- \u7c7b\u578b\u4e0d\u4e00\u81f4\n\n  ```sql\n  select * from big where name = 123;\t\t-- \u672a\u547d\u4e2d\n  select * from big where email = 123;\t-- \u672a\u547d\u4e2d\n  \n  \u7279\u6b8a\u7684\u4e3b\u952e\uff1a\n  \tselect * from big where id = \"123\";\t-- \u547d\u4e2d\n  ```\n\n- \u4f7f\u7528\u4e0d\u7b49\u4e8e\n\n  ```sql\n  select * from big where name != \"\u6b66\u6c9b\u9f50\";\t\t\t\t-- \u672a\u547d\u4e2d\n  select * from big where email != \"wupeiqi@live.com\";  -- \u672a\u547d\u4e2d\n  \n  \u7279\u6b8a\u7684\u4e3b\u952e\uff1a\n  \tselect * from big where id != 123;\t-- \u547d\u4e2d\n  ```\n\n- or\uff0c\u5f53or\u6761\u4ef6\u4e2d\u6709\u672a\u5efa\u7acb\u7d22\u5f15\u7684\u5217\u624d\u5931\u6548\u3002\n\n  ```sql\n  select * from big where id = 123 or password=\"xx\";\t\t\t-- \u672a\u547d\u4e2d\n  select * from big where name = \"wupeiqi\" or password=\"xx\";\t-- \u672a\u547d\u4e2d\n  \u7279\u522b\u7684\uff1a\n  \tselect * from big where id = 10 or password=\"xx\" and name=\"xx\"; -- \u547d\u4e2d\n  ```\n\n- \u6392\u5e8f\uff0c\u5f53\u6839\u636e\u7d22\u5f15\u6392\u5e8f\u65f6\u5019\uff0c\u9009\u62e9\u7684\u6620\u5c04\u5982\u679c\u4e0d\u662f\u7d22\u5f15\uff0c\u5219\u4e0d\u8d70\u7d22\u5f15\u3002\n\n  ```sql\n  select * from big order by name asc;     -- \u672a\u547d\u4e2d\n  select * from big order by name desc;    -- \u672a\u547d\u4e2d\n  \n  \u7279\u522b\u7684\u4e3b\u952e\uff1a\n  \tselect * from big order by id desc;  -- \u547d\u4e2d\n  ```\n\n- like\uff0c\u6a21\u7cca\u5339\u914d\u65f6\u3002\n\n  ```sql\n  select * from big where name like \"%u-12-19999\";\t-- \u672a\u547d\u4e2d\n  select * from big where name like \"_u-12-19999\";\t-- \u672a\u547d\u4e2d\n  select * from big where name like \"wu-%-10\";\t\t-- \u672a\u547d\u4e2d\n  \n  \u7279\u522b\u7684\uff1a\n  \tselect * from big where name like \"wu-1111-%\";\t-- \u547d\u4e2d\n  \tselect * from big where name like \"wuw-%\";\t\t-- \u547d\u4e2d\n  ```\n\n- \u4f7f\u7528\u51fd\u6570\n\n  ```sql\n  select * from big where reverse(name) = \"wupeiqi\";  -- \u672a\u547d\u4e2d\n  \n  \u7279\u522b\u7684\uff1a\n  \tselect * from big where name = reverse(\"wupeiqi\");  -- \u547d\u4e2d\n  ```\n\n- \u6700\u5de6\u524d\u7f00\uff0c\u5982\u679c\u662f\u8054\u5408\u7d22\u5f15\uff0c\u8981\u9075\u5faa\u6700\u5de6\u524d\u7f00\u539f\u5219\u3002\n\n  ```sql\n  \u5982\u679c\u8054\u5408\u7d22\u5f15\u4e3a\uff1a(name,password)\n      name and password       -- \u547d\u4e2d\n      name                 \t-- \u547d\u4e2d\n      password                -- \u672a\u547d\u4e2d\n      name or password       \t-- \u672a\u547d\u4e2d\n  ```\n\n  \n\n\u5e38\u89c1\u7684\u65e0\u6cd5\u547d\u4e2d\u7d22\u5f15\u7684\u60c5\u51b5\u5c31\u662f\u4e0a\u8ff0\u7684\u793a\u4f8b\u3002<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7d22\u5f15\u539f\u7406\uff1a\u5e95\u5c42\u662f\u56e0\u4e3a\u57fa\u4e8eB+Tree\u7684\u6570\u636e\u7ed3\u6784\u5b58\u50a8 \u5728\u521b\u5efa\u6570\u636e\u5e93\u8868\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u6307\u5b9a\u4e0d\u540c\u7684\u5f15\u64ce\u3002 \u5e38\u89c1\u7d22\u5f15 \u4f1a\u6709 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-636","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/comments?post=636"}],"version-history":[{"count":2,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/636\/revisions"}],"predecessor-version":[{"id":639,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/posts\/636\/revisions\/639"}],"wp:attachment":[{"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/media?parent=636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/categories?post=636"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.chan.ink\/index.php\/wp-json\/wp\/v2\/tags?post=636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}