{"id":667,"date":"2021-07-03T22:13:23","date_gmt":"2021-07-03T14:13:23","guid":{"rendered":"https:\/\/fireinsect.top\/?p=667"},"modified":"2021-07-30T20:45:52","modified_gmt":"2021-07-30T12:45:52","slug":"%e6%95%b0%e6%8d%ae%e5%ba%93%e5%9f%ba%e7%a1%80","status":"publish","type":"post","link":"https:\/\/fireinsect.top\/index.php\/2021\/07\/03\/%e6%95%b0%e6%8d%ae%e5%ba%93%e5%9f%ba%e7%a1%80\/","title":{"rendered":"\u6570\u636e\u5e93\u57fa\u7840"},"content":{"rendered":"\n<p>\u6570\u636e\u5e93\u88ab\u5206\u4e3a\u5173\u7cfb\u578b\u6570\u636e\u5e93\u548c\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93<\/p>\n\n\n\n<p>\u4f7f\u7528Mysql\u662f\u57fa\u4e8e\u5173\u7cfb\u578b\u6570\u636e\u5e93<\/p>\n\n\n\n<p>\u800cSQL\u5168\u540d Structured Query Language(\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00)\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u8bed\u8a00\uff0cMySQL\u624d\u662f\u6570\u636e\u5e93\u672c\u8eab\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"has-large-font-size\">\u8868\u7ed3\u6784\u8bbe\u8ba1\u89c4\u8303<\/p>\n\n\n\n<p>\u4e92\u8054\u7f51\u516c\u53f8\u5728\u4f7f\u7528 MySQL \u5728\u8bbe\u8ba1\u8868\u7ed3\u6784\u65f6\uff0c\u9700\u8981\u9075\u4ece\u4ee5\u4e0b\u7684\u89c4\u8303\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u8868\u5fc5\u987b\u8981\u6709\u4e3b\u952e\u3002<\/li><li>\u4e00\u4e2a\u5b57\u6bb5\u53ea\u8868\u793a\u4e00\u4e2a\u542b\u4e49\u3002<\/li><li>\u603b\u662f\u5305\u542b\u4e24\u4e2a\u65e5\u671f\u5b57\u6bb5:gmt_created(\u521b\u5efa\u65e5\u671f),gmt_modified(\u4fee\u6539\u65e5\u671f)\uff0c\u4e14\u8fd9\u4e24\u4e2a\u5b57\u6bb5\u4e0d\u5e94\u8be5\u5305\u542b\u6709\u989d\u5916\u7684\u4e1a\u52a1\u903b\u8f91\u3002<\/li><li>MySQL \u4e2d\uff0cgmt_created\u3001gmt_modified \u4f7f\u7528DATETIME \u7c7b\u578b\u3002<\/li><li>\u7981\u6b62\u4f7f\u7528\u590d\u6742\u6570\u636e\u7c7b\u578b\uff08\u6570\u7ec4\uff0c\u81ea\u5b9a\u4e49\u7c7b\u578b\u7b49\uff09\u3002<\/li><li>\u7981\u6b62\u4f7f\u7528\u7269\u7406\u5916\u952e\uff0c\u4f7f\u7528\u903b\u8f91\u5916\u952e<\/li><li>\u7981\u6b62\u7269\u7406\u5220\u9664\uff0c\u4f7f\u7528\u903b\u8f91\u5220\u9664 is_deleted <\/li><\/ol>\n\n\n\n<p><span class=\"has-inline-color has-vivid-red-color\">\u903b\u8f91\u5220\u9664\uff08\u82f1\u8bed\uff1alogical deletion\uff09\uff0c\u53c8\u88ab\u79f0\u8f6f\u5220\u9664\u3001\u5047\u5220\u9664\uff0c\u662f\u4e00\u79cd\u6570\u636e\u5e93\u64cd\u4f5c\uff0c\u4f7f\u7528\u6807\u8bb0\u5c06\u6570\u636e\u6807\u4e3a\u4e0d\u53ef\u7528\uff0c\u800c\u4e0d\u4ece\u6570\u636e\u5e93\u5220\u9664\u6570\u636e\u672c\u8eab\u3002\u4f7f\u7528\u9002\u5f53\u7684\u65b9\u6cd5\u53ef\u6062\u590d\u88ab\u5220\u9664\u7684\u6570\u636e\u3002\u5728\u5546\u4e1a\u516c\u53f8\u7684\u5b9e\u9645\u5f00\u53d1\u4e2d\u4f1a\u4f7f\u7528\u3002<\/span><\/p>\n\n\n\n<p class=\"has-large-font-size\">\u4e3b\u952e<\/p>\n\n\n\n<p>\u6bcf\u4e00\u5f20\u6570\u636e\u5e93\u8868\u90fd\u53ef\u4ee5\u6709\u4e00\u4e2a\u4e3b\u952e\uff08primary key\uff09\uff0c\u4e3b\u952e\u6700\u5927\u7684\u4f5c\u7528\u5c31\u662f\u7528\u6765\u6807\u8bc6\u6570\u636e\uff0c\u6570\u636e\u5c31\u50cf\u6211\u4eec\u4eba\uff0c\u540d\u5b57\u53ef\u80fd\u4f1a\u91cd\u590d\uff0c\u751f\u65e5\u53ef\u80fd\u4f1a\u4e00\u6837\uff0c\u4f46\u662f\u8eab\u4efd\u8bc1\u53f7\u662f\u80af\u5b9a\u6bcf\u4e2a\u4eba\u90fd\u4e0d\u4e00\u6837\u7684\uff0c\u8eab\u4efd\u8bc1\u53f7\u5c31\u662f\u793e\u4f1a\u4f53\u7cfb\u8fa8\u522b\u6211\u4eec\u6bcf\u4e2a\u4eba\u8c01\u662f\u8c01\u7684\u952e\u3002<\/p>\n\n\n\n<p>\u4e3b\u952e\u62e5\u6709\u4ee5\u4e0b\u7684\u7279\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"list1 wp-block-list\"><li>\u4e3b\u952e\u662f\u4e00\u4e2a\u7279\u6b8a\u5b57\u6bb5<\/li><li>\u8868\u683c\u53ef\u4ee5\u6ca1\u6709\u4e3b\u952e\uff0c\u4f46\u662f\u6700\u591a\u53ea\u80fd\u62e5\u6709\u4e00\u4e2a\u4e3b\u952e<\/li><li>\u4e3b\u952e\u7684\u503c\u4e0d\u80fd\u4e3aNULL\uff0c\u5fc5\u987b\u6709\u5bf9\u5e94\u7684\u503c<\/li><li>\u4e3b\u952e\u7684\u503c\u5fc5\u987b\u662f\u7edd\u5bf9\u552f\u4e00\u7684\uff0c\u5373\u4e0d\u80fd\u51fa\u73b0\u4e24\u4e2a\u76f8\u540c\u7684\u4e3b\u952e\u503c\uff0c\u6bd4\u5982\u540d\u5b57\u5c31\u4e0d\u80fd\u4f5c\u4e3a\u4e3b\u952e\uff0c\u56e0\u4e3a\u4f1a\u51fa<\/li><li>\u73b0\u91cd\u540d\u7684\u60c5\u51b5\u3002<\/li><li>\u6211\u4eec\u4e00\u822c\u4f7f\u7528\u4e3b\u952e\u548c\u5176\u4ed6\u8868\u8fdb\u884c\u5173\u8054<\/li><\/ul>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-large-font-size\">SQL\u5e38\u7528\u6570\u636e\u7c7b\u578b<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u7c7b\u578b<\/th><th>\u542b\u4e49<\/th><\/tr><\/thead><tbody><tr><td>VARCHAR<\/td><td>\u53ef\u53d8\u7684\u957f\u5b57\u7b26\u4e32,\u53ef\u4ee5\u7c7b\u6bd4\u4e8eJava\u4e2d\u7684String\u7c7b\u578b<\/td><\/tr><tr><td>INT<\/td><td>\u6574\u578b,\u548cJava\u4e2d\u7684int\u7c7b\u578b\u4e00\u81f4<\/td><\/tr><tr><td>DOUBLE<\/td><td>\u6d6e\u70b9\u578b,\u548cJava\u4e2d\u7684double\u7c7b\u578b\u4e00\u81f4,\u4e00\u822c\u4e0d\u52a0\u957f\u5ea6\u9650\u5236<\/td><\/tr><tr><td>DATETIME<\/td><td>\u65f6\u95f4\u7c7b\u578b,\u957f\u5ea6\u4e3a0,\u683c\u5f0f\u4e3aYYYY-MM-DD HH:MM:SS,\u503c\u4e3a2019-12-31 23:59:59<\/td><\/tr><tr><td>BIGINT<\/td><td>\u957f\u6574\u5f62,\u548cJava\u4e2d\u7684long\u7c7b\u578b\u4e00\u81f4<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"has-large-font-size\">CRUD<\/p>\n\n\n\n<p>\u5728\u8ba1\u7b97\u673a\u7a0b\u5e8f\u8bed\u8a00\u4e2d\uff0c\u521b\u5efa\uff08Create\uff09\u3001\u8bfb\u53d6\uff08Read\uff09\u3001\u66f4\u65b0\uff08Update\uff09\u3001\u5220\u9664\uff08Delete\uff09\uff0c\u4e5f\u5c31\u662fCRUD\uff1b\u8fd9\u662f\u4e00\u8fde\u4e32\u5e38\u89c1\u7684\u52a8\u4f5c\u884c\u4e3a\uff0c\u800c\u5176\u884c\u4e3a\u901a\u5e38\u662f\u4e3a\u4e86\u9488\u5bf9\u67d0\u4e2a\u7279\u5b9a\u8d44\u6e90\u6240\u4f5c\u51fa\u7684\u4e3e\u52a8\uff08\u4f8b\u5982\uff1a\u521b\u5efa\u6570\u636e\u3001\u8bfb\u53d6\u6570\u636e\u7b49\uff09\u3002\u8fd9\u56db\u4e2a\u884c\u4e3a\u6700\u5e38\u89c1\u7684\u7528\u9014\u80fd\u591f\u5728\u4f7f\u7528SQL\u6570\u636e\u5e93\u4e0e\u7f51\u7ad9\u7684API\u7aef\u53e3\u65f6\u53d1\u73b0\u3002\u8fd9\u4e2a\u8bcd\u8bed\uff08CRUD\uff09\u6700\u65e9\u88ab\u8bb0\u8f7d\u4e8eJames Martin\u6240\u64b0\u5199\u7684Managing the Data-base Environment\u4e66\u4e2d\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u82f1\u6587<\/th><th>\u4e2d\u6587<\/th><th>SQL<\/th><th>HTTP<\/th><\/tr><\/thead><tbody><tr><td>CREATE <\/td><td>\u521b\u5efa<\/td><td>INSERT\uff08\u63d2\u5165\uff09<\/td><td>POST<\/td><\/tr><tr><td>READ<\/td><td>\u8bfb\u53d6<\/td><td>SELECT\uff08\u67e5\u8be2\uff09<\/td><td>GET<\/td><\/tr><tr><td>UPDATE<\/td><td>\u66f4\u65b0<\/td><td>UPDATE <\/td><td>POST<\/td><\/tr><tr><td>DELETE<\/td><td>\u5220\u9664<\/td><td>DELETE<\/td><td>DELETE<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-large-font-size\">\u8868\u7684\u521b\u5efa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>CREATE<\/strong> <strong>TABLE<\/strong> `<strong>user<\/strong>`(  <strong><span class=\"has-inline-color has-vivid-red-color\">\/\/\u521b\u5efa\u4e00\u4e2a\u53ebuser\u7684\u8868<\/span><\/strong>\n`id` <strong>INT<\/strong>(10)<strong>NOT<\/strong> <strong>NULL<\/strong>, <span class=\"has-inline-color has-vivid-red-color\"><strong>\/\/\u521b\u5efa\u5b57\u6bb5   \u5176\u8bed\u6cd5\u7ed3\u6784\u57fa\u672c\u7b26\u5408\uff1a\u5b57\u6bb5\u540d+\u6570\u636e\u7c7b\u578b+\u957f\u5ea6+\u662f\u5426\u4e3a NUL<\/strong><\/span>\n<strong><span class=\"has-inline-color has-vivid-red-color\">\n\/*id\u662f\u5b57\u6bb5\u540d\uff0c\u6211\u4eec\u7528``\u8fd9\u4e2a\u7b26\u53f7\u628a\u5b83\u5305\u542b\u8d77\u6765\u3002\nINT \u662f\u6570\u636e\u7c7b\u578b\uff0c\u8868\u793a id \u8fd9\u4e2a\u5b57\u6bb5\u662f INT \u503c\n(10)\u8868\u793a id \u6700\u957f\u4e3a 10 \u4f4d\ndatetime \u7c7b\u578b\u6ca1\u6709\u957f\u5ea6\uff0c\u6240\u4ee5\u4e0d\u7528\u5b9a\u4e49\u957f\u5ea6\nNOT NULL \u8868\u793a\u8fd9\u4e2a\u5b57\u6bb5\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u4e5f\u5c31\u662f\u5fc5\u987b\u8981\u8f93\u5165\u503c\uff0c\u5426\u5219\u5c31\u4f1a\u62a5\u9519\uff0c\u5982\u679c\u8fd9\u4e2a\u503c\u53ef\u4ee5\u4e3a\u4e0d\n\u8f93\u5165\u503c\uff0c\u90a3\u4e48\u4e0d\u52a0 NOT NUL*\/\n<\/span><\/strong>\n`mobile` <strong>VARCHAR<\/strong>(11) <strong>NOT<\/strong> <strong>NULL<\/strong>,\n`nickname` <strong>VARCHAR<\/strong>(40) <strong>NOT<\/strong> <strong>NULL<\/strong>,\n`gmt_created` datetime ,\n`gmt_modified` datetime <strong>NOT<\/strong> <strong>NULL<\/strong>,<span class=\"has-inline-color has-vivid-red-color\"><strong>\/\/\u8868\u793a\u521b\u5efa\u4fee\u6539\u65f6\u95f4<\/strong><\/span>\n<strong>PRIMARY<\/strong> KEY ( `id` ) <strong><span class=\"has-inline-color has-vivid-red-color\">\/\/\u7ea6\u5b9a\u4e3b\u952e \u5373\u610f\u601d\u4e3a\u8be5\u8868\u7684\u4e3b\u952e\u4e3a`id`<\/span><\/strong>\n<strong><span class=\"has-inline-color has-vivid-red-color\">\n\/*\u4e3b\u952e\u5fc5\u987b\u662f\u5df2\u7ecf\u7ea6\u5b9a\u7684\u5b57\u6bb5\n \u4e3b\u952e\u4e0d\u80fd\u4e3a\u7a7a\n \u4e3b\u952e\u7684\u503c\u4e0d\u80fd\u91cd\u590d\n \u4e3b\u952e\u6700\u5927\u7684\u4f5c\u7528\u662f\u6807\u8bc6\uff0c\u6240\u4ee5\u5b83\u6700\u597d\u662f\u7531\u8ba1\u7b97\u673a\u751f\u6210\uff0c\u4eba\u5de5\u4e0d\u5e72\u9884\u4e3b\u952e\u751f\u6210\u540e\u7684\u503c*\/\n<\/span><\/strong>\n)ENGINE=InnoDB <strong>DEFAULT<\/strong> CHARSET=utf8; <strong><span class=\"has-inline-color has-vivid-red-color\">\/\/\u8bbe\u7f6e\u50a8\u5b58\u5f15\u64ce\u548c\u7f16\u7801\u65b9\u5f0f<\/span><\/strong>\n\/*<strong><span class=\"has-inline-color has-vivid-red-color\">\u8fd9\u53e5\u8bdd\u7684\u610f\u601d\u662f\u50a8\u5b58\u5f15\u64ce\u4e3a InnoDB,\u9ed8\u8ba4\u7f16\u7801\u65b9\u5f0f\u4e3a utf-8\u3002 InnoDB \u662f MySQL \u7684\u9ed8\u8ba4\u50a8\u5b58\u5f15\u64ce,utf-8 \u662f\u4e00\u79cd\u7f16\u7801\u65b9\u5f0f<\/span><\/strong>*\/<\/code><\/pre>\n\n\n\n<p>\u5b9a\u4e49\u5b57\u6bb5\u7684\u8bed\u53e5\uff0c\u8bed\u53e5\u95f4\u6709<strong><span class=\"has-inline-color has-vivid-red-color\"><code> , <\/code><\/span><\/strong>\uff0c\u6700\u540e\u4e00\u53e5\u540e\u9762\u6ca1\u6709<br>SQL \u8bed\u53e5\u4ee5 <strong><span class=\"has-inline-color has-vivid-red-color\"><code>;<\/code> <\/span><\/strong>\u7ed3\u5c3e\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u6709\u65f6\u4f7f\u7528\u4ee5\u4e0b\u6765\u5b9a\u4e49\u4e3b\u952e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">`id` <strong>INT<\/strong> UNSIGNED AUTO_INCREMENT<\/code><\/pre>\n\n\n\n<p>\u8fd9\u53e5\u8bdd\u7684\u610f\u601d\u662f\uff0cid \u4f1a\u4ece 1 \u5f00\u59cb\u81ea\u589e\uff0c\u7b2c\u4e8c\u4e2a\u4e3a 2\uff0c\u7b2c\u4e09\u4e2a\u4e3a 3\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002<\/p>\n\n\n\n<p>\u5f53\u6211\u4eec\u9700\u8981\u5220\u9664\u8868\u65f6\u4e00\u822c\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>drop<\/strong> <strong>table<\/strong> table_name;<\/code><\/pre>\n\n\n\n<p>\u6709\u65f6\u4e5f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>DROP<\/strong> <strong>TABLE<\/strong> IF <strong>EXISTS<\/strong> table_name;\/\/\u8868\u793a\u5982\u679c\u5b58\u5728\u8fd9\u4e2a\u8868<\/code><\/pre>\n\n\n\n<p class=\"has-large-font-size\">\u63d2\u5165\u8bed\u53e5<\/p>\n\n\n\n<p>\u63d2\u5165\u8bed\u53e5\u5b8c\u6574\u5199\u6cd5\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>INSERT<\/strong> <strong>INTO<\/strong> table_name(field1,field2,...fieldN)  \/\/field\u8868\u793a\u8868\u5185\u8981\u63d2\u5165\u7684\u5b57\u6bb5\u540d\n<strong>VALUES<\/strong>\n(value1,value2,...valueN);  \/\/value \u8868\u793a\u5b57\u6bb5\u6570\u636e\uff0c\u5176\u4e0e\u4e0a\u65b9field\u4e00\u4e00\u5bf9\u5e94<\/code><\/pre>\n\n\n\n<ul class=\"list1 wp-block-list\"><li>varchar\u7c7b\u578b\u63d2\u5165\u65f6\u8981\u7528  \u2018  \u2019  \u5305\u88f9<\/li><li>\u5bf9\u4e8e\u6570\u5b57  int  \u7c7b\u578b\u53ef\u4ee5\u76f4\u63a5\u5199 1  <\/li><li> \u5bf9\u4e8e  datetime \u7c7b\u578b\u53ef\u4ee5\u901a\u8fc7 now() \u8fd9\u4e2a\u51fd\u6570\u6765\u83b7\u53d6<strong>\u670d\u52a1\u5668<\/strong>\u5f53\u524d\u65f6\u95f4<\/li><\/ul>\n\n\n\n<p class=\"has-medium-font-size\">\u63d2\u5165\u8bed\u53e5\u7684\u7b80\u5316<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u5982\u679c\u4e3b\u952e\u8bbe\u7f6e\u4e3a\u81ea\u589e\uff0c\u5219\u53ef\u4ee5\u4e0d\u63d2\u5165\u4e3b\u952e\u548c\u5bf9\u5e94\u7684\u6570\u636e<\/li><li>\u5982\u679c\u63d2\u5165\u7684\u662f\u6240\u6709\u7684\u5b57\u6bb5\uff0c\u53ef\u4ee5\u7701\u7565\u5b57\u6bb5\u540d\uff0c\u76f4\u63a5\u63d2\u5165\u503c\uff0c\u4f46\u662f\u7c7b\u578b\u5fc5\u987b\u5168\u90e8\u4e00\u81f4,\u6bd4\u5982\uff1a<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>INSERT<\/strong> <strong>INTO<\/strong> table_name\n<strong>VALUES<\/strong>\n(value1,value2,...valueN);<\/code><\/pre>\n\n\n\n<p>\u6ce8\uff1a\u4e24\u79cd\u7b80\u5316\u4e0d\u80fd\u540c\u65f6\u4f7f\u7528<\/p>\n\n\n\n<p>\u5982\u679c\u8981\u4e00\u6b21\u6027\u63d2\u5165\u5927\u91cf\u6570\u636e\uff0c\u53ef\u4ee5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>INSERT<\/strong> <strong>INTO<\/strong> table_name\n<strong>VALUES<\/strong>\n(value1,value2,...valueN),\n(value1,value2,...valueN);<\/code><\/pre>\n\n\n\n<p><strong>\u63d2\u5165\u4e00\u6761\u6570\u636e\u5bf9\u5e94\u8868\u683c\u4e2d\u7684\u4e00\u884c,\u5f53\u89c4\u5b9a\u4e3a NOT NULL \u7684\u5b57\u6bb5\u6ca1\u6709\u7ed9\u5230\u503c\u65f6,\u63d2\u5165\u8bed\u53e5\u4f1a\u62a5\u9519<\/strong>\u3002<\/p>\n\n\n\n<p class=\"has-large-font-size\">\u67e5\u8be2\u8bed\u53e5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> field1,field2,.... <strong>FROM<\/strong> table_name; \/\/field\u8868\u793a\u8981\u67e5\u8be2\u7684\u5b57\u6bb5\uff0ctable_name\u8868\u793a\u8868\u540d<\/code><\/pre>\n\n\n\n<p>\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  id,\n  name\n<strong>FROM<\/strong>\n  people;<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u9700\u8981\u67e5\u8be2\u6240\u4ee5\u5b57\u6bb5\u5219\u4e5f\u53ef\u4ee5\u5199\u6210<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> people; \/\/\u67e5\u8be2\u6240\u6709\u5b57\u6bb5<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">\u6761\u4ef6\u67e5\u8be2\uff08where\u8bed\u53e5\uff09<\/p>\n\n\n\n<p>\u5b9e\u9645\u4f7f\u7528\u4e2d\u6211\u4eec\u5f80\u5f80\u662f\u5b9a\u5411\u5bf9\u6570\u636e\u5e93\u8fdb\u884c\u67e5\u8be2\uff0c\u6b64\u65f6\u6211\u4eec\u5c31\u9700\u8981\u4f7f\u7528  where  \u8bed\u53e5\u6765\u9650\u5236\u6761\u4ef6\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> table_name <strong>WHERE<\/strong> <strong>condition<\/strong>;  \/\/condition\u8868\u793a\u6761\u4ef6<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong>\n  *\n<strong>FROM<\/strong>\n  people\n<strong>where<\/strong>\n  age &gt; 50;<\/code><\/pre>\n\n\n\n<p>\u8868\u793a\u4e86\u67e5\u8be2\u5e74\u9f84\u5927\u4e8e50\u5c81\u7684\u6240\u6709\u5b57\u6bb5<\/p>\n\n\n\n<p class=\"has-large-font-size\">Limit\u8bed\u53e5\uff08\u9650\u5236\uff09<\/p>\n\n\n\n<p>\u5728\u5b9e\u9645\u5de5\u4f5c\u7684\u6570\u636e\u67e5\u8be2\u4e2d,\u6211\u4eec\u6709\u65f6\u5019\u9700\u8981\u8fd4\u56de\u6307\u5b9a\u884c,\u6bd4\u5982\u6211\u60f3\u67e5\u8be2\u7b26\u5408\u67d0\u4e2a\u6761\u4ef6\u7684\u524d\u5341\u4e2a\u6570\u636e,\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u4f7f\u7528LIMIT\u5b50\u53e5\u6765\u52a0\u5f3a\u67e5\u8be2\u529f\u80fd\u3002\u683c\u5f0f\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> table_name LIMIT <strong>parameter<\/strong>;  \/\/\u5176\u4e2dparameter\u8868\u793alimit\u8bed\u53e5\u7684\u53c2\u6570<\/code><\/pre>\n\n\n\n<p>\u5177\u4f53\u4f7f\u7528\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> people LIMIT 5, 6;\n\/\/\u8868\u793a\u4ece\u8868\u7684\u7b2c5+1\u884c\u5f00\u59cb\uff08\u6570\u636e\u5e93\u4e2d\u7684\u884c\u4ece\u7b2c0\u884c\u5f00\u59cb\u8ba1\u6570\uff09\uff0c\u67e5\u8be26\u6761\u8bb0\u5f55\u3002\u5373\u67e5\u8be26\u201411\u884c\u662f\u6570\u636e<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> people LIMIT 5;\n\/\/\u8868\u793a\u67e5\u8be2\u7b2c0-5\u884c\u4e0e\u4e00\u4e0b\u4ee3\u7801\u4f5c\u7528\u76f8\u540c\n<strong>SELECT<\/strong> * <strong>FROM<\/strong> timi_adc LIMIT 0,5;<\/code><\/pre>\n\n\n\n<p>\u7279\u6b8a\u4f7f\u7528\u4e5f\u53ef\u5982\u4e0b\u67e5\u8be2\u7b2cx\u884c\u6570\u636e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> people LIMIT x, 1;<\/code><\/pre>\n\n\n\n<p>Limit \u8bed\u53e5\u5f80\u5f80\u4e0e\u5176\u4ed6\u8bed\u53e5\u5982 where \u4e00\u8d77\u4f7f\u7528\u5982<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> people <strong>WHERE<\/strong> age&gt;10 LIMIT 5;<\/code><\/pre>\n\n\n\n<p>\u5373\u67e5\u8be2\u5e74\u9f84\u5927\u4e8e10\u7684\u524d\u4e94\u6761\u6570\u636e\uff08ps where\u4e0elimit\u4f4d\u7f6e\u7684\u524d\u540e\u51b3\u5b9a\u8bed\u53e5\u53d1\u751f\u7684\u5148\u540e\uff09<\/p>\n\n\n\n<p class=\"has-large-font-size\">\u6392\u5e8f\uff08Order by\uff09\u8bed\u53e5<\/p>\n\n\n\n<p>\u6211\u4eec\u4f1a\u9700\u8981\u5bf9\u67e5\u8be2\u7684\u6570\u636e\u8fdb\u884c\u6392\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528\u6392\u5e8f\u8bed\u53e5\uff0c\u5177\u4f53\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> table_name <strong>ORDER<\/strong> <strong>BY<\/strong> field_name;<\/code><\/pre>\n\n\n\n<p>\u6392\u5e8f\u9ed8\u8ba4\u6309\u7167\u5347\u5e8f\u6392\u5e8f\uff0c\u5bf9\u4e8eint,double\u800c\u8a00\uff0c\u662f\u4ece\u5c0f\u5230\u5927\uff0c\u5bf9\u4e8evarchar\u800c\u8a00\uff0c\u662f\u4ece\u5b57\u6bcdA\u5230Z\uff0c\u5bf9\u4e8e<br>datetime\u800c\u8a00\uff0c\u662f\u4ece\u8fc7\u53bb\u5230\u73b0\u5728\u3002<\/p>\n\n\n\n<p class=\"has-medium-font-size\">DESC\u5173\u952e\u8bcd<\/p>\n\n\n\n<p>\u6392\u5e8f\u4e00\u822c\u4f7f\u7528\u5347\u5e8f\u6392\u5e8f\uff0c\u5173\u952e\u8bcd\u4e3aASC(\u4e00\u822c\u4e0d\u5199)\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u52a0\u4e0aDESC\u5173\u952e\u8bcd\u53d8\u4e3a\u964d\u5e8f\u6392\u5e8f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> table_name <strong>ORDER<\/strong> <strong>BY<\/strong> field_name <strong>DESC<\/strong>;<\/code><\/pre>\n\n\n\n<p>\u4e0e\u5176\u4ed6\u53e5\u5b50\u8fde\u7528\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>SELECT<\/strong> * <strong>FROM<\/strong> people <strong>WHERE<\/strong> age&gt;10 OREDER BY age LIMIT 5;<\/code><\/pre>\n\n\n\n<p>\u6211\u4eec\u4e00\u822c\u5148\u6392\u5e8f\u518dlimit<\/p>\n\n\n\n<p class=\"has-large-font-size\">\u66f4\u65b0\/\u5220\u9664<\/p>\n\n\n\n<p class=\"has-medium-font-size\">\u66f4\u65b0\u8bed\u53e5\uff08update\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">UPDATE \u8868\u540d\u79f0 <strong>SET<\/strong> \u5217\u540d\u79f0 = \u65b0\u503c <strong>WHERE<\/strong> \u5217\u540d\u79f0 = \u67d0\u503c<\/code><\/pre>\n\n\n\n<p>\u4f7f\u7528Update\u65f6\u5fc5\u987b\u4f7f\u7528 where \u6765\u505a\u9650\u5236\uff0c\u5426\u5219 update \u4f1a\u5bf9\u6574\u5217\u8d77\u4f5c\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">UPDATE\n  timi_adc\n<strong>SET<\/strong>\n  ban_rate = 0.01\n<strong>WHERE<\/strong>\n  hero_name = '\u827e\u7433';<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">\u5220\u9664\u8bed\u53e5\uff08delete\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\"><strong>DELETE<\/strong> <strong>FROM<\/strong> table_name [<strong>WHERE<\/strong> Clause]<\/code><\/pre>\n\n\n\n<p>\u7531\u4e8e\u5220\u9664\u8bed\u53e5\u662f\u4e0d\u53ef\u6062\u590d\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u52a1\u5fc5\u8981\u589e\u52a0WHERE\u8bed\u53e5\uff0c\u5426\u5219\u5c06\u4f1a\u5220\u9664\u6574\u5f20\u8868\u683c\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<p>delete \u53ea\u662f\u5220\u9664\u8868\u5185\u662f\u6570\u636e\uff0c\u5982\u679c\u8981\u5220\u9664\u6574\u4e2a\u8868\u4f7f\u7528 <code>drop table +\u8868\u540d<\/code> \u7684\u8bed\u53e5,\u5f53\u7136\uff0c\u6211\u4eec\u4e00\u822c\u4e5f\u8fd9\u4e48\u5199 <code><strong>DROP<\/strong> <strong>TABLE<\/strong> IF <strong>EXISTS<\/strong> table_name; <\/code><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6570\u636e\u5e93\u88ab\u5206\u4e3a\u5173\u7cfb\u578b\u6570\u636e\u5e93\u548c\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93 \u4f7f\u7528Mysql\u662f\u57fa\u4e8e\u5173\u7cfb\u578b\u6570\u636e\u5e93 \u800cSQL\u5168\u540d Structured [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[6,1],"tags":[],"class_list":["post-667","post","type-post","status-publish","format-standard","hentry","category-6","category-wcd"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/667"}],"collection":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/comments?post=667"}],"version-history":[{"count":28,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/667\/revisions"}],"predecessor-version":[{"id":733,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/posts\/667\/revisions\/733"}],"wp:attachment":[{"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/media?parent=667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/categories?post=667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fireinsect.top\/index.php\/wp-json\/wp\/v2\/tags?post=667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}