{"id":1232,"date":"2022-02-21T00:04:07","date_gmt":"2022-02-20T16:04:07","guid":{"rendered":"http:\/\/www.tra56.com\/?p=1232"},"modified":"2022-02-21T00:04:07","modified_gmt":"2022-02-20T16:04:07","slug":"1232","status":"publish","type":"post","link":"https:\/\/www.tra56.com\/1232.html","title":{"rendered":"Mysql\u7d22\u5f15\u4f18\u5316"},"content":{"rendered":"
\u5728\u6211\u4eec\u65e5\u5e38\u4f7f\u7528\u6570\u636e\u5e93\u7684\u65f6\u5019\uff0c\u80af\u5b9a\u907f\u514d\u4e0d\u4e86\u5bf9\u6570\u636e\u5e93\u7684\u4f18\u5316\u3002\u90a3\u4e48\u5bf9\u6570\u636e\u5e93\u7684\u4f18\u5316\u53c8\u5c11\u4e86\u4e0d \u662f\u7684\uff0c\u5efa\u7acb \u5199\u4e0b\u8fd9\u7bc7\u6587\u7ae0\u5c31\u662f\u4e3a\u4e86\u8bb0\u5f55\u4e00\u4e0b\u5bf9\u7d22\u5f15\u7684\u4f18\u5316\uff0c\u5408\u7406\u5efa\u7acb\u7d22\u5f15\u3002<\/p>\n MySQL\u5b98\u65b9\u5bf9\u7d22\u5f15\u7684\u5b9a\u4e49\u4e3a\uff1a\u7d22\u5f15(Index)\u662f\u5e2e\u52a9MySQL\u9ad8\u6548\u83b7\u53d6\u6570\u636e\u7684\u6570\u636e\u7ed3\u6784\u3002<\/p>\n \u6211\u4eec\u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u4e3a\uff1a\u5feb\u901f\u67e5\u627e\u6392\u597d\u5e8f\u7684\u4e00\u79cd\u6570\u636e\u7ed3\u6784\u3002Mysql\u7d22\u5f15\u4e3b\u8981\u6709\u4e24\u79cd\u7ed3\u6784\uff1aB+Tree\u7d22\u5f15\u548cHash\u7d22\u5f15\u3002<\/p>\n \u7d22\u5f15\u5c31\u76f8\u5f53\u4e8e\u5b57\u5178\u524d\u7684\u76ee\u5f55\uff0c\u5982\u679c\u8fd9\u4e2a\u76ee\u5f55\u5212\u5206\u89c4\u5212\u66f4\u597d\uff0c\u90a3\u4e48\u6211\u4eec\u627e\u5230\u60f3\u8981\u7684\u6570\u636e\u5c31\u4f1a\u66f4\u65b9\u4fbf\uff0c\u4e5f\u5c31\u63d0\u9ad8\u4e86\u67e5\u8be2\u7684\u6548\u7387\u3002<\/p>\n \u7d22\u5f15\u7684\u7c7b\u578b\u6709\uff1a<\/p>\n normal\uff1a\u8868\u793a\u666e\u901a\u7d22\u5f15<\/p>\n<\/li>\n unique\uff1a\u8868\u793a\u552f\u4e00\u7684\uff0c\u4e0d\u5141\u8bb8\u6709\u91cd\u590d\u503c\u7684\u7d22\u5f15<\/p>\n<\/li>\n full textl: \u8868\u793a\u5168\u6587\u641c\u7d22\u7684\u7d22\u5f15\uff0c\u7528\u4e8e\u641c\u7d22\u5f88\u957f\u4e00\u7bc7\u6587\u7ae0\u7684\u65f6\u5019\uff0c\u6548\u679c\u6700\u597d\u3002<\/p>\n<\/li>\n<\/ul>\n \u7d22\u5f15\u4e0d\u662f\u8d8a\u591a\u8d8a\u597d\uff0c\u56e0\u4e3a\u6bcf\u6b21\u66f4\u65b0\u3001\u63d2\u5165\u6570\u636e\uff0c\u5c31\u9700\u8981\u5bf9\u7d22\u5f15\u6587\u4ef6\u8fdb\u884c\u53d8\u52a8\uff0c\u4f1a\u51cf\u4f4e\u8be5\u7c7b\u578b\u64cd\u4f5c\u7684\u6267\u884c\u6548\u7387\u3002<\/p>\n \u5982\u679c\u5efa\u7acb\u7d22\u5f15\u7684\u5b57\u6bb5\u592a\u591a\uff0c\u5f71\u54cd\u5c31\u4f1a\u5f88\u5927\u3002<\/p>\n \u6240\u4ee5\u6211\u4eec \u5728\u7ecf\u5e38\u7528\u6765\u5f53\u67e5\u8be2\u6761\u4ef6 \u5728\u6570\u636e\u7684\u7ef4\u5ea6\u6bd4\u8f83\u5927\u7684\u5b57\u6bb5\u4e0a\u5efa\u7acb\u7d22\u5f15\u3002<\/p>\n<\/li>\n \u5bf9\u6570\u636e\u8f83\u5c0f\u7684\u5217\u4f7f\u7528\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7d22\u5f15\u6587\u4ef6\u66f4\u5c0f\uff0c\u540c\u65f6\u5185\u5b58\u4e2d\u4e5f\u53ef\u4ee5\u88c5\u8f7d\u66f4\u591a\u7684\u7d22\u5f15\u952e\u3002<\/p>\n<\/li>\n \u4e3a\u8f83\u957f\u7684\u5b57\u7b26\u4e32\u4f7f\u7528\u524d\u7f00\u7d22\u5f15\u3002 \u5e38\u89c1\u7684\u53ef\u4ee5\u7528\u4e8e\u5efa\u7acb\u7d22\u5f15\u7684\u5b57\u6bb5\u573a\u666f\uff1a<\/p>\n \u2460 \u7528\u6237id \u2461 \u5546\u54c1\u540d \u2462 \u65e5\u671f \u5408\u9002\u7684\u8fd8\u6709\u5f88\u591a\u5f88\u591a\u573a\u666f\uff0c\u9700\u8981\u5404\u4f4d\u5c0f\u4f19\u4f34\u81ea\u5df1\u597d\u597d\u601d\u91cf\u3002<\/p>\n \u5e76\u4e0d\u662f\u5efa\u7acb\u4e86\u7d22\u5f15\u5c31\u5728\u67e5\u8be2\u8bed\u53e5\u4e2d\u751f\u6548\u3002<\/p>\n \u5f53\u8bed\u53e5\u4e2d\u5e26\u6709or\u7684\u65f6\u5019\uff0c\u7d22\u5f15\u4f1a\u5931\u6548<\/p>\n<\/li>\n \u5f53\u7d22\u5f15\u7684\u5b57\u6bb5\u4f7f\u7528like\u67e5\u8be2\uff0c\u5e76\u4e14\u4f7f\u7528\u4e86 \u5f53\u7d22\u5f15\u7684\u5b57\u6bb5\u662f\u5b57\u7b26\u7c7b\u578b\uff0c\u4f46\u662f\u50a8\u5b58\u7684\u503c\u662f\u6570\u5b57\uff0c\u6bd4\u5982 user_name:\u2019123456\u2019\uff0c\u5728\u67e5\u8be2\u8bed\u53e5\u4e2d\u8981 user_name = \u2018123456\u2019\u800c \u5f53\u4f7f\u7528\u7684\u6761\u4ef6\u8bed\u53e5\uff0c\u9884\u8ba1\u7ed3\u679c\u6570\u91cf\u8d85\u8fc7\u5168\u8868\u6570\u636e\u7684\u4e00\u5b9a\u6bd4\u4f8b\u65f6\uff0c\u4f1a\u8f6c\u4e3a\u5168\u8868\u626b\u63cf\uff08mysql\u4e00\u822c\u662f30%\u5de6\u53f3\uff09\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u5728\u5efa\u7acb\u7d22\u5f15\u7684\u65f6\u5019\u8981\u9009\u62e9\u7ef4\u5ea6\uff08\u533a\u522b\u5ea6\uff09\u6bd4\u8f83\u9ad8\u7684\u5217\uff0c\u6027\u522b\u8fd9\u79cd\u5b57\u6bb5\u4e0d\u9002\u5408\u5efa\u7acb\u7d22\u5f15\u3002<\/p>\n<\/li>\n \u8bed\u53e5\u4e2d\u51fa\u73b0\u5217\u6570\u636e\u8fd0\u7b97\u624d\u5224\u65ad\u7684\uff0c\u6bd4\u5982where age \u2013 10 > 0 \u6bcf\u4e00\u884c\u90fd\u8981\u8fd0\u7b97\u4e4b\u540e\u624d\u77e5\u9053\u662f\u5426\u5927\u4e8e0 \u6240\u4ee5\u5c31\u662f\u5168\u8868\u626b\u63cf\uff0c\u5982\u679cage > 10 \u5219\u53ef\u4f7f\u7528\u7d22\u5f15\u3002\u4f7f\u7528\u51fd\u6570\u8f6c\u6362\u5217\u6570\u636e\u4e5f\u4e00\u6837\u539f\u7406\u3002<\/p>\n<\/li>\n \u7ec4\u5408\u7d22\u5f15\u65f6\u4f7f\u7528\u7684\u6761\u4ef6\u8bed\u53e5\u3002<\/p>\n<\/li>\n<\/ul>\n \u4e0a\u9762\u4e3e\u4f8b\u7684\u4e00\u4e9b\u573a\u666f\u90fd\u662f\u6bd4\u8f83\u5bb9\u6613\u7406\u89e3\u7684\u3002\u7ec4\u5408\u7d22\u5f15\u8fd8\u6ca1\u6d89\u53ca\uff0c\u5f80\u4e0b\u7ee7\u7eed\u4ecb\u7ecd\u3002<\/p>\n<\/blockquote>\n \u5148\u6765\u770b\u4e00\u6761\u8bed\u53e5<\/p>\n \u5047\u8bbe\u5728\u8fd9\u4e2a\u8868\u4e2d\uff0cuser_name\u5b57\u6bb5\u548ccreate_time\u90fd\u662f\u5efa\u7acb\u4e86\u7d22\u5f15\u7684\u3002\u4e5f\u6ca1\u6709\u53d1\u751f\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u7b49\u60c5\u51b5\u3002<\/p>\n \u95ee\u9898\uff1a\u8be5\u8bed\u53e5\u6709\u51e0\u4e2a\u7d22\u5f15\u751f\u6548\uff1f<\/p>\n<\/blockquote>\n \u662f2\u4e2a\u5417\uff1f\u5e76\u4e0d\u662f\u8fd9\u6837\u5b50\u7684\u3002<\/p>\n \u867d\u7136\u4e24\u4e2a\u5b57\u6bb5\u7684\u7d22\u5f15\u90fd\u6ca1\u6709\u95ee\u9898\uff0c\u5982\u679c\u5355\u72ec\u4f7f\u7528\u4e5f\u90fd\u80fd\u751f\u6548\u3002<\/p>\n \u4f46\u662f\uff1a \u600e\u4e48\u8bc1\u660e\uff1f\u4f7f\u7528 \u53ea\u8981\u5728sql\u8bed\u53e5\u6700\u524d\u9762\u52a0\u4e0a\u8be5\u8bed\u6cd5\uff0c\u5219\u4f1a\u663e\u793a\u67e5\u8be2\u7c7b\u578b\u76f8\u5173\u7684\u4fe1\u606f\u3002<\/p>\n <\/p>\n \u6211\u5efa\u7acb\u4e86\u4e24\u4e2a\u7d22\u5f15\uff0c\u90fd\u80fd\u7528\uff0c\u90fd\u662f\u672c\u6b21\u67e5\u8be2\u53ea\u80fd\u4f7f\u7528\u4e00\u4e2a\u3002<\/p>\n \u57fa\u4e8e\u8fd9\u4e2a\u60c5\u51b5\uff0c\u4f1a\u5f15\u7533\u51fa \u7ec4\u5408\u7d22\u5f15<\/p>\n<\/li>\n \u591a\u4e2a\u5355\u5b57\u6bb5\u7d22\u5f15\u51b2\u7a81<\/p>\n<\/li>\n<\/ul>\n \u5148\u6765\u8bf4\u8bf4\u7ec4\u5408\u7d22\u5f15\u5427\uff0c\u6211\u4eec\u5728\u65b0\u5efa\u7d22\u5f15\u7684\u65f6\u5019\uff08\u53ef\u89c6\u5316\u8f6f\u4ef6\uff09\uff0c\u662f\u8fd9\u6837\u5b50\u7684\u9875\u9762<\/p>\n <\/p>\n \u5f53\u6211\u4eec\u52fe\u9009\u4e0a2\u4e2a\u6216\u80052\u4e2a\u4ee5\u4e0a \u5c31\u80fd\u628a\u5b83\u53eb\u4e3a \u53ef\u4ee5\u770b\u5230\u8fd8\u6709\u8c03\u6574\u987a\u5e8f\u7684\u529f\u80fd<\/p>\n \u5728\u7ec4\u5408\u7d22\u5f15\u4e2d\uff0c \u5047\u8bbe\u6211\u4eec\u6709\u8fd9\u6837\u4e00\u4e2a\u7d22\u5f15\uff1anew : a,b,c \u5b57\u6bb5<\/p>\n \u5728\u67e5\u8be2\u65f6\u4f7f\u7528 \u5982\u679c\u6211\u4eec\u4f7f\u7528 \u8fd8\u662f\u8981\u626b\u63cf\u5168\u90e8\u884c<\/p>\n \u7ec4\u5408\u7d22\u5f15\u8981\u6ce8\u610f\u5b57\u6bb5\u987a\u5e8f\uff0c\u662f\u6307\u5728\u521b\u5efa\u7d22\u5f15\u65f6\u5019\u7684\u6392\u5e8f\uff0c\u800c\u4e0d\u662fsql\u8bed\u53e5\u4e2dwhere\u7684\u987a\u5e8f\uff0c\u6211\u4eec\u4f7f\u7528 \u90a3\u4e48\u7ec4\u5408\u7d22\u5f15\u7684\u5b57\u6bb5\u987a\u5e8f\u8981\u5982\u4f55\u6392\u6bd4\u8f83\u597d?<\/p>\n \u540e\u9762\u4f1a\u6709\u65b0\u7684\u4e00\u7bc7\u6587\u7ae0\u4f1a\u8bb2\u8fd9\u4e2a<\/p>\n \u5982\u679c\u6211\u4eec\u5728\u8868\u4e2d\uff0c\u62e5\u6709\u4e24\u4e2a\u7d22\u5f15\uff0c\u6bd4\u5982 \u73b0\u5728\u6709\u8fd9\u6837\u5b50\u7684\u6570\u636e\u91cf\uff1a \u5047\u8bbe\u6709\u8fd9\u6837\u5b50\u4e00\u6761\u8bed\u53e5\uff1a<\/p>\n \u6709\u4e24\u4e2a\u5b57\u6bb5\u90fd\u6709\u7d22\u5f15\u53ef\u7528\uff0cmysql\u4f1a\u9009\u62e9\u4e00\u4e2a\u4f7f\u7528\u3002\u8fd9\u662f\u5c5e\u4e8emysql\u7684\u5185\u90e8\u5904\u7406\u5224\u65ad<\/p>\n \u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u7528user_phone\u7d22\u5f15\u751f\u6548\u7684\u8bdd\uff0c\u4f1a\u5f88\u5feb\u5f97\u5230\u7ed3\u679c\uff08\u5148\u7b5b\u9009\u51fa100\u6761 \u518d\u7b5b\u9009\uff09<\/p>\n \u5982\u679cuser_name\u751f\u6548\uff0c\u5219\u8981\u5148\u7b5b\u9009100W\u6761\u6570\u636e\uff0c\u518d\u7b5b\u9009user_phone<\/p>\n mysql\u7684\u5185\u90e8\u5224\u65ad\u53ef\u80fd\u4f7f\u5f97user_name\u7d22\u5f15\u751f\u6548\uff0c\u6b64\u65f6\u6548\u7387\u5c31\u4f1a\u5f88\u4f4e\u4e86\uff0c\u6211\u4eec\u53ef\u4ee5 phone\u662f\u7d22\u5f15\u540d \u662f\u65b0\u5efa\u7684\u65f6\u5019\u586b\u7684<\/p>\n \u6b64\u79cd\u60c5\u51b5\u51fa\u73b0\u7684\u6982\u7387\u6bd4\u8f83\u5c0f\uff0c\u6bd5\u7adfmysql\u7684\u89e3\u91ca\u5668\u5f88\u590d\u6742\uff0c\u4e5f\u505a\u4e86\u8db3\u591f\u591a\u7684\u4f18\u5316\u3002\u53ea\u6709\u6392\u67e5\u6162\u65e5\u5fd7\u5e76\u4e14\u5206\u6790\u786e\u5b9a\u7d22\u5f15\u51b2\u7a81\u7684\u60c5\u51b5\u624d\u9700\u8981\u5f3a\u5236\u4f7f\u7528\u7d22\u5f15\u3002<\/p>\n<\/blockquote>\n \u53ea\u5728\u7ecf\u5e38\u4f7f\u7528\u7684\u5b57\u6bb5\u4e0a\u5efa\u7acb\u7d22\u5f15\uff0c\u5426\u5219\u4f1a\u62d6\u6162\u6570\u636e\u66f4\u65b0\u548c\u63d2\u5165\u7684\u901f\u5ea6\u3002<\/p>\n<\/li>\n \u53ea\u5728\u7ef4\u5ea6\u9ad8\u7684\u5b57\u6bb5\u4e0a\u5efa\u7acb\u7d22\u5f15\uff0c\u5426\u5219\u4f1a\u4f7f\u5f97\u6570\u636e\u6bd4\u4f8b\u8fc7\u5927\uff0c\u8f6c\u4e3a\u5168\u8868\u626b\u63cf\u3002<\/p>\n<\/li>\n \u4f18\u5148\u5bf9\u6570\u636e\u91cf\u6bd4\u8f83\u5c0f\u7684\u5b57\u6bb5\u5efa\u7acb\u7d22\u5f15\uff0c\u53ef\u4ee5\u4f7f\u7d22\u5f15\u6587\u4ef6\u66f4\u5c0f\uff0c\u540c\u65f6\u5185\u5b58\u4e2d\u4e5f\u53ef\u4ee5\u88c5\u8f7d\u66f4\u591a\u7684\u7d22\u5f15\u952e\u3002<\/p>\n<\/li>\n \u89c4\u8303sql\u8bed\u53e5\u7684\u751f\u6210\uff0c\u7981\u6b62\u53d1\u751f \u957f\u5b57\u7b26\u4e32\u53ef\u4ee5\u4f7f\u7528\u524d\u7f00\u7d22\u5f15\uff0c\u53ea\u5bf9\u5b57\u7b26\u4e32\u7684\u524d\u9762\u4e00\u5b9a\u5b57\u7b26\u957f\u5ea6\u5efa\u7acb\u7d22\u5f15\u3002<\/p>\n<\/li>\n \u7ec4\u5408\u7d22\u5f15\u7684\u987a\u5e8f\u5408\u7406\u4f18\u5316\uff08\u4f1a\u6709\u65b0\u6587\u7ae0\u4ecb\u7ecd\uff09<\/p>\n<\/li>\n \u5f53\u591a\u4e2a\u5355\u5b57\u6bb5\u7d22\u5f15\u53d1\u751f\u51b2\u7a81\u65f6\uff0c\u5f3a\u5236\u4f7f\u7528\u67d0\u4e2a\u7d22\u5f15\u3002<\/p>\n<\/li>\n<\/ul>\n <\/p>\n","protected":false},"excerpt":{"rendered":" \u5199\u5728\u524d\u9762 \u5728\u6211\u4eec\u65e5\u5e38\u4f7f\u7528\u6570\u636e\u5e93\u7684\u65f6\u5019\uff0c\u80af\u5b9a\u907f\u514d\u4e0d\u4e86\u5bf9\u6570\u636e\u5e93\u7684\u4f18\u5316\u3002\u90a3\u4e48\u5bf9\u6570\u636e\u5e93\u7684\u4f18\u5316\u53c8\u5c11\u4e86\u4e0d\u7d22\u5f15\u7684\u77e5\u8bc6\u3002 \u662f\u7684 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,10],"tags":[],"class_list":["post-1232","post","type-post","status-publish","format-standard","hentry","category-linux","category-php"],"_links":{"self":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1232"}],"collection":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/comments?post=1232"}],"version-history":[{"count":1,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1232\/revisions"}],"predecessor-version":[{"id":1233,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/posts\/1232\/revisions\/1233"}],"wp:attachment":[{"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/media?parent=1232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/categories?post=1232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tra56.com\/wp-json\/wp\/v2\/tags?post=1232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\u7d22\u5f15<\/code>\u7684\u77e5\u8bc6\u3002<\/p>\n
\u7d22\u5f15<\/code>\u80fd\u6781\u5927\u5730\u63d0\u9ad8\u67e5\u8be2\u7684\u6548\u7387\u3002\u90a3\u4e48\u4f60\u77e5\u9053\u5417\uff0c\u5982\u679c\u5408\u7406\u5efa\u7acb\u7d22\u5f15\uff0c\u53ef\u4ee5\u66f4\u5927\u5730\u69a8\u51fa\u6570\u636e\u5e93\u7684\u6027\u80fd\u2014\u2014\u4e5f\u5c31\u7b49\u540c\u4e8e\u8fdb\u4e00\u6b65\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002<\/p>\n
\u4ec0\u4e48\u662f\u7d22\u5f15<\/h1>\n
\u5efa\u7acb\u7d22\u5f15\u7684\u573a\u666f<\/h1>\n
\u53ea\u5728\u5408\u7406\u7684\u5b57\u6bb5\u4e0a\u5efa\u7acb\u7d22\u5f15<\/code>\u3002<\/p>\n
(where,on,group by,order by)<\/code>\u7684\u5b57\u6bb5\u4e0a\u5efa\u7acb\u7d22\u5f15\u3002<\/p>\n<\/li>\n
\u6bd4\u5982\u6570\u636e\u7684\u957f\u5ea6\u5927\u90e8\u5206\u662f150\u4e2a\u5b57\u8282\uff0c\u6211\u4eec\u53ea\u5efa\u7acb\u524d100\u4e2a\u5b57\u8282\u7684\u7d22\u5f15\u3002<\/code><\/p>\n<\/li>\n<\/ul>\n
\u5728\u8ba2\u5355\u8868\u4e2d\u7684\u7528\u6237id\u5b57\u6bb5\u4e0a\u5efa\u7acb\u7d22\u5f15\uff0c\u6839\u636e\u7528\u6237id\u7b5b\u9009\u8ba2\u5355\uff0c\u5219\u4f1a\u5f88\u5feb\u67e5\u8be2\u51fa\u7528\u6237\u7684\u8ba2\u5355\u3002
\u7528\u6237\u4e00\u822c\u662f\u5728\u81ea\u5df1\u7684\u540e\u53f0\u67e5\u770b\u8ba2\u5355\uff0c\u6240\u4ee5\u8868\u4e2d\u7684\u5176\u4ed6\u7528\u6237\u6570\u636e\u4e0e\u4ed6\u65e0\u5173\uff0c\u5982\u679c\u6ca1\u6709\u5efa\u7acb\u7d22\u5f15\uff0c\u6bcf\u6b21\u67e5\u8be2\u90fd\u662f\u5168\u8868\u626b\u63cf\uff0c\u5219\u4f1a\u5f88\u6162\u3002\uff08\u6211\u4eec\u6bcf\u4e2a\u4eba\u5728\u6dd8\u5b9d\u5e73\u53f0\u4e0a\u5360\u7684\u8ba2\u5355\u6bd4\u4f8b\u90fd\u4e0d\u52300.0001\uff09<\/p>\n
\u540c\u4e0a\uff0c\u5982\u679c\u4e0d\u5efa\u7acb\u7d22\u5f15\uff0c\u6211\u4eec\u5728\u6dd8\u5b9d\u8f93\u5165\u6846\u641c\u7d22\u952e\u76d8<\/code>\uff0c\u600e\u4e48\u5feb\u901f\u67e5\u8be2\u51fa\u952e\u76d8\u5546\u54c1\uff1f<\/p>\n
\u5e38\u7528\u7684\u6d3b\u8dc3\u6570\u636e\uff0c\u4e00\u822c\u90fd\u662f\u662f\u6700\u8fd1\u4ea7\u751f\u7684\uff0c\u5f88\u5c11\u4eba\u6ca1\u4e8b\u53bb\u7ffb\u534a\u5e74\u524d\u7684\u8ba2\u5355\u6570\u636e\u5427\uff1f<\/p>\n\u7d22\u5f15\u4e0d\u751f\u6548\u7684\u573a\u666f<\/h1>\n
\u524d\u901a\u914d<\/code>\u6bd4\u5982
%Siam<\/code>\uff0c\u7d22\u5f15\u5931\u6548\u3002\u540e\u901a\u914d\u4f1a\u751f\u6548
Siam%<\/code><\/p>\n<\/li>\n
\u4e0d\u80fd<\/code> user_name = 123456 \u5426\u5219\u53d1\u751f\u7c7b\u578b\u8f6c\u6362\uff0c\u7d22\u5f15\u5931\u6548\uff0c\u5176\u4ed6\u7c7b\u578b\u7684\u5b57\u6bb5 \u6bd4\u5982\u65e5\u671f\u7b49 \u4e5f\u540c\u7406<\/p>\n<\/li>\n
\n
mysql\u4e2d\uff0c\u591a\u4e2a\u7d22\u5f15\u540c\u65f6\u4f7f\u7528\uff1f<\/h2>\n
select * from test where user_name = <\/code>
'siam_007'<\/code>
and<\/code>
create_time = 1563280050<\/code><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
<\/p>\n\n
MySQL\u4f1a\u4ece\u53ef\u7528\u7684\u7d22\u5f15\u4e2d\u731c\u6d4b\u51fa\u6548\u7387\u6700\u9ad8\u7684\u4e00\u4e2a\u7d22\u5f15\u5e76\u4f7f\u7528\u5b83<\/code><\/p>\n
explain<\/code>\u8bed\u53e5\uff08\u8be6\u89e3\u53ef\u4ee5\u5728\u7f51\u4e0a\u5176\u4ed6\u8d44\u6599\u627e\u5230\uff09<\/p>\n
Explain select * from mysql_index_test where user_name = <\/code>
'siam_007'<\/code>
and<\/code>
create_time = 1563280050<\/code><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
<\/p>\n\n
\u4e24\u4e2a\u77e5\u8bc6\u70b9<\/code><\/p>\n<\/blockquote>\n
\u7ec4\u5408\u7d22\u5f15<\/h2>\n
\u7ec4\u5408\u7d22\u5f15<\/code>\u4e86<\/p>\n
\u5b57\u6bb5\u987a\u5e8f<\/code>\u4e5f\u662f\u6781\u4e3a\u91cd\u8981\u7684\u3002<\/p>\n
where a = 1 and b = 2 and c= 3<\/code>\u3002\u90a3\u4e48\u8fd9\u4e2a\u8bed\u53e5\u80af\u5b9a\u662f\u751f\u6548\u7684\u3002<\/p>\n
where b = 2 and c =3<\/code>\u6ca1\u6709a\u6761\u4ef6 \u800ca\u53c8\u662f\u5728\u7ec4\u5408\u7d22\u5f15\u4e2d\u6700\u5de6\u4fa7\u7684\uff0c\u90a3\u4e48\u7d22\u5f15\u5c31\u4e0d\u4f1a\u751f\u6548\u3002<\/p>\n
where a,c where a,b where b,a,c<\/code> \u8fd9\u6837\u5b50\u4f7f\u7528\u90fd\u662f\u53ef\u4ee5\u751f\u6548\u7684\u3002<\/p>\n
where b = 2 and a = 1 and c = 3<\/code>\u4e5f\u662f \u53ef\u4ee5\u751f\u6548\u7684<\/p>\n
\u591a\u4e2a\u5355\u5b57\u6bb5\u7d22\u5f15\u51b2\u7a81<\/h2>\n
user_name \u7528\u6237\u540d, user_phone \u7528\u6237\u624b\u673a\u53f7<\/code><\/p>\n
100W\u6761\u6570\u636e user_name=\u2019\u6211\u662f\u7528\u6237\u540d\u2019
100\u6761\u6570\u636e user_phone=\u2019110\u2032
5\u6761\u6570\u636e user_name=\u2019\u6211\u662f\u7528\u6237\u540d\u2019 and user_phone=\u2019110\u2032<\/p>\nselect * from test where user_name = <\/code>
'\u6211\u662f\u7528\u6237\u540d'<\/code>
and<\/code>
user_phone=<\/code>
'110'<\/code><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u5f3a\u5236\u4f7f\u7528\u67d0\u4e2a\u7d22\u5f15<\/code><\/p>\n
select * from test index(phone) where user_name = <\/code>
'\u6211\u662f\u7528\u6237\u540d'<\/code>
and<\/code>
user_phone=<\/code>
'110'<\/code><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
<\/p>\n\n
\u4f18\u5316 \uff08\u603b\u7ed3\uff09<\/h1>\n
\u5217\u8fd0\u7b97<\/code>\u3001
\u7c7b\u578b\u8f6c\u6362<\/code>\u7684\u53d1\u751f\u3002<\/p>\n<\/li>\n