{"id":151,"date":"2018-10-25T17:32:52","date_gmt":"2018-10-25T09:32:52","guid":{"rendered":"http:\/\/www.maoyunwang.top\/?p=151"},"modified":"2018-10-25T17:32:52","modified_gmt":"2018-10-25T09:32:52","slug":"mysql%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/blog.tongyunli.top\/?p=151","title":{"rendered":"Mysql\u603b\u7ed3"},"content":{"rendered":"\n<p>\u5982\u679c\u611f\u89c9\u4ee5\u4e0b\u6392\u7248\u4e0d\u9002\u5408\u9605\u8bfb \u8bf7\u4e0b\u8f7d<a href=\"http:\/\/maoyunweb.com\/index.php?share\/file&amp;user=1&amp;sid=pRq4KW75\">word\u7248\u672c<\/a>(\u63d0\u53d6\u7801:med0r)<\/p>\n\n\n<h1><\/h1>\n<p>\u76ee\u5f55<\/p>\n<p><a href=\"#_Toc429465381\">\u4e00\u3001\u6570\u636e\u5e93\u6982\u8ff0&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 1<\/a><\/p>\n<p><a href=\"#_Toc429465382\">\u4e8c\u3001\u6570\u636e\u5e93\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. 2<\/a><\/p>\n<p><a href=\"#_Toc429465383\">\u4e09\u3001sql\u6982\u8ff0&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 3<\/a><\/p>\n<p><a href=\"#_Toc429465384\">\u56db\u3001Sql\u7684\u5206\u7c7b&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 4<\/a><\/p>\n<p><a href=\"#_Toc429465385\">4.1 DDL:\u64cd\u4f5c\u6570\u636e\u5e93\u3001\u8868\u3001\u5217\u7b49&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 4<\/a><\/p>\n<p><a href=\"#_Toc429465386\">* 4.1.1\u64cd\u4f5c\u6570\u636e\u5e93&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 4<\/a><\/p>\n<p><a href=\"#_Toc429465387\">* 4.1.2\u64cd\u4f5c\u6570\u636e\u8868&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 5<\/a><\/p>\n<p><a href=\"#_Toc429465388\">4.2 DML\u64cd\u4f5c(\u91cd\u8981)&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 6<\/a><\/p>\n<p><a href=\"#_Toc429465389\">4.2.1\u63d2\u5165\u64cd\u4f5c\uff1aINSERT:&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 6<\/a><\/p>\n<p><a href=\"#_Toc429465390\">4.2.2 \u4fee\u6539\u64cd\u4f5c UPDATE: &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;\u8bed\u6cd5\uff1aUPDATE \u8868\u540d SET \u5217\u540d1=\u5217\u503c1\uff0c\u5217\u540d2=\u5217\u503c2 \u3002\u3002\u3002 WHERE \u5217\u540d=\u503c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<\/a><\/p>\n<p><a href=\"#_Toc429465391\">4.2.3 \u5220\u9664\u64cd\u4f5c DELETE:&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 8<\/a><\/p>\n<p><a href=\"#_Toc429465392\">4.3 DQL\u64cd\u4f5c&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 8<\/a><\/p>\n<p><a href=\"#_Toc429465393\">\u4e94\u3001 \u6570\u636e\u7684\u5b8c\u6574\u6027&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 17<\/a><\/p>\n<p><a href=\"#_Toc429465394\">1\u3001\u5b9e\u4f53\u5b8c\u6574\u6027&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 17<\/a><\/p>\n<p><a href=\"#_Toc429465395\">1.1\u4e3b\u952e\u7ea6\u675f\uff08primary key\uff09&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. 18<\/a><\/p>\n<p><a href=\"#_Toc429465396\">1.2\u552f\u4e00\u7ea6\u675f(unique)\uff1a &nbsp;&nbsp;&nbsp; CREATE TABLE student(&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. 18<\/a><\/p>\n<p><a href=\"#_Toc429465397\">1.3\u81ea\u52a8\u589e\u957f\u5217(auto_increment)&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. 19<\/a><\/p>\n<p><a href=\"#_Toc429465398\">sqlserver\u6570\u636e\u5e93 (identity)&nbsp; oracle\u6570\u636e\u5e93( sequence)&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 19<\/a><\/p>\n<p><a href=\"#_Toc429465399\">2\u3001 \u57df\u5b8c\u6574\u6027&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. 19<\/a><\/p>\n<p><a href=\"#_Toc429465400\">1.1 \u6570\u636e\u7c7b\u578b:\uff08\u6570\u503c\u7c7b\u578b\u3001\u65e5\u671f\u7c7b\u578b\u3001\u5b57\u7b26\u4e32\u7c7b\u578b\uff09&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 19<\/a><\/p>\n<p><a href=\"#_Toc429465401\">1.2 \u975e\u7a7a\u7ea6\u675f\uff1anot null&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. 19<\/a><\/p>\n<p><a href=\"#_Toc429465402\">1.3 \u9ed8\u8ba4\u503c\u7ea6\u675f default&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. 19<\/a><\/p>\n<p><a href=\"#_Toc429465403\">3\u3001 \u5f15\u7528\u5b8c\u6574\u6027\uff08\u53c2\u7167\u5b8c\u6574\u6027\uff09&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 20<\/a><\/p>\n<p><a href=\"#_Toc429465404\">4\u3001\u3000\u8868\u4e0e\u8868\u4e4b\u95f4\u7684\u5173\u7cfb&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 20<\/a><\/p>\n<p><a href=\"#_Toc429465405\">\u516d\u3001\u591a\u8868\u67e5\u8be2&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 21<\/a><\/p>\n<p><a href=\"#_Toc429465406\">\u4e03\u3001MySQL\u4e2d\u7684\u51fd\u6570&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 30<\/a><\/p>\n<p><a href=\"#_Toc429465407\">\u516b\u3001MySQL\u6570\u636e\u5e93\u7684\u5907\u4efd\u4e0e\u6062\u590d&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 30<\/a><\/p>\n<p><a href=\"#_Toc429465408\">1\u3000\u751f\u6210SQL\u811a\u672c&nbsp; \u5bfc\u51fa\u6570\u636e&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;. 30<\/a><\/p>\n<p><a href=\"#_Toc429465409\">2\u3000\u6267\u884cSQL\u811a\u672c \u6062\u590d\u6570\u636e&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; 30<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1><a name=\"_Toc429465381\"><\/a>\u4e00\u3001\u6570\u636e\u5e93\u6982\u8ff0<\/h1>\n<p>\u6570\u636e\u5e93\uff08DataBase\uff0cDB\uff09\uff1a\u6307\u957f\u671f\u4fdd\u5b58\u5728\u8ba1\u7b97\u673a\u7684\u5b58\u50a8\u8bbe\u5907\u4e0a\uff0c\u6309\u7167\u4e00\u5b9a\u89c4\u5219\u7ec4\u7ec7\u8d77\u6765\uff0c\u53ef\u4ee5\u88ab\u5404\u79cd\u7528\u6237\u6216\u5e94\u7528\u5171\u4eab\u7684\u6570\u636e\u96c6\u5408\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff08DataBase Management System\uff0cDBMS\uff09\uff1a\u6307\u4e00\u79cd\u64cd\u4f5c\u548c\u7ba1\u7406\u6570\u636e\u5e93\u7684\u5927\u578b\u8f6f\u4ef6\uff0c\u7528\u4e8e\u5efa\u7acb\u3001\u4f7f\u7528\u548c\u7ef4\u62a4\u6570\u636e\u5e93\uff0c\u5bf9\u6570\u636e\u5e93\u8fdb\u884c\u7edf\u4e00\u7ba1\u7406\u548c\u63a7\u5236\uff0c\u4ee5\u4fdd\u8bc1\u6570\u636e\u5e93\u7684\u5b89\u5168\u6027\u548c\u5b8c\u6574\u6027\u3002\u7528\u6237\u901a\u8fc7\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u8bbf\u95ee\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u6570\u636e\u5e93\u8f6f\u4ef6\u5e94\u8be5\u4e3a<strong>\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf<\/strong>\uff0c\u6570\u636e\u5e93\u662f\u901a\u8fc7\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u521b\u5efa\u548c\u64cd\u4f5c\u7684\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u6570\u636e\u5e93\uff1a\u5b58\u50a8\u3001\u7ef4\u62a4\u548c\u7ba1\u7406\u6570\u636e\u7684\u96c6\u5408\u3002<\/p>\n<h1><a name=\"_Toc429465382\"><\/a>\u4e8c\u3001\u6570\u636e\u5e93\u7684\u5b89\u88c5\u4e0e\u914d\u7f6e<\/h1>\n<p>* \u5b89\u88c5<\/p>\n<p>* \u53c2\u7167\u56fe\u89e3<\/p>\n<p>* \u4e00\u8def\u4e0b\u4e00\u6b65<\/p>\n<p>* \u5378\u8f7d<\/p>\n<p>1.\u505c\u6b62mysql\u670d\u52a1&nbsp;&nbsp; net stop mysql&nbsp;&nbsp;&nbsp;&nbsp; \u542f\u52a8mysql\u670d\u52a1&nbsp; net start mysql<\/p>\n<p>2.\u5378\u8f7dmysql<\/p>\n<p>3.\u627e\u5230mysql \u5b89\u88c5\u76ee\u5f55\u4e0b\u7684 my.ini&nbsp;&nbsp; datadir=&#8221;C:\/ProgramData\/MySQL\/MySQL Server 5.5\/Data\/&#8221;<\/p>\n<p>* \u8fd0\u884c<\/p>\n<p>* \u5b89\u88c5\u6210\u529f\u4e86\u6253\u5f00cmd&nbsp; &#8211;&gt; mysql -uroot -p\u4f60\u7684\u5bc6\u7801<\/p>\n<p>* \u4fee\u6539mysql root\u7528\u6237\u5bc6\u7801<\/p>\n<p>1) \u505c\u6b62mysql\u670d\u52a1 \u8fd0\u884c\u8f93\u5165services.msc \u505c\u6b62mysql\u670d\u52a1<\/p>\n<p>\u6216\u8005 cmd &#8211;&gt;&nbsp; net stop mysql<\/p>\n<p>2) \u5728cmd\u4e0b \u8f93\u5165 mysqld &#8211;skip-grant-tables \u542f\u52a8\u670d\u52a1\u5668 \u5149\u6807\u4e0d\u52a8 \uff08\u4e0d\u8981\u5173\u95ed\u8be5\u7a97\u53e3\uff09<\/p>\n<p>3) \u65b0\u6253\u5f00cmd \u8f93\u5165mysql -u root -p \u4e0d\u9700\u8981\u5bc6\u7801<\/p>\n<p>use mysql;<\/p>\n<p>update user set password=password(&#8216;abc&#8217;) WHERE User=&#8217;root&#8217;;<\/p>\n<p>4) \u5173\u95ed\u4e24\u4e2acmd\u7a97\u53e3 \u5728\u4efb\u52a1\u7ba1\u7406\u5668\u7ed3\u675fmysqld \u8fdb\u7a0b<\/p>\n<p>5) \u5728\u670d\u52a1\u7ba1\u7406\u9875\u9762 \u91cd\u542fmysql \u670d\u52a1<\/p>\n<p>\u5bc6\u7801\u4fee\u6539\u5b8c\u6210<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>* \u914d\u7f6e<\/p>\n<p>* \u53c2\u7167\u56fe\u89e3<\/p>\n<p>* \u5230\u9009\u62e9\u5b57\u7b26\u96c6\u65f6\u505c<\/p>\n<h1><a name=\"_Toc429465383\"><\/a>\u4e09\u3001sql\u6982\u8ff0<\/h1>\n<p>SQL\uff1aStructure Query Language\u3002\uff08\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00\uff09<\/p>\n<p>SQL\u88ab\u7f8e\u56fd\u56fd\u5bb6\u6807\u51c6\u5c40\uff08ANSI\uff09\u786e\u5b9a\u4e3a\u5173\u7cfb\u578b\u6570\u636e\u5e93\u8bed\u8a00\u7684\u7f8e\u56fd\u6807\u51c6\uff0c\u540e\u6765\u88ab\u56fd\u9645\u5316\u6807\u51c6\u7ec4\u7ec7\uff08ISO\uff09\u91c7\u7eb3\u4e3a\u5173\u7cfb\u6570\u636e\u5e93\u8bed\u8a00\u7684\u56fd\u9645\u6807\u51c6\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u5404\u6570\u636e\u5e93\u5382\u5546\u90fd\u652f\u6301ISO\u7684SQL\u6807\u51c6\u3002<strong>\u666e\u901a\u8bdd<\/strong><\/p>\n<p>\u5404\u6570\u636e\u5e93\u5382\u5546\u5728\u6807\u51c6\u7684\u57fa\u7840\u4e0a\u505a\u4e86\u81ea\u5df1\u7684\u6269\u5c55\u3002<strong>\u65b9\u8a00<\/strong><\/p>\n<h1><a name=\"_Toc429465384\"><\/a>\u56db\u3001Sql\u7684\u5206\u7c7b<\/h1>\n<p>DDL(*)\uff08Data Definition Language\uff09\uff1a\u6570\u636e\u5b9a\u4e49\u8bed\u8a00\uff0c\u7528\u6765\u5b9a\u4e49\u6570\u636e\u5e93\u5bf9\u8c61\uff1a\u5e93\u3001\u8868\u3001\u5217\u7b49\uff1b<\/p>\n<p>DML(**)\uff08Data Manipulation Language\uff09\uff1a\u6570\u636e\u64cd\u4f5c\u8bed\u8a00\uff0c\u7528\u6765\u5b9a\u4e49\u6570\u636e\u5e93\u8bb0\u5f55\uff08\u6570\u636e\uff09\uff1b<\/p>\n<p>DCL\uff08Data Control Language\uff09\uff1a\u6570\u636e\u63a7\u5236\u8bed\u8a00\uff0c\u7528\u6765\u5b9a\u4e49\u8bbf\u95ee\u6743\u9650\u548c\u5b89\u5168\u7ea7\u522b\uff1b<\/p>\n<p>DQL(*****)\uff08Data Query Language\uff09\uff1a\u6570\u636e\u67e5\u8be2\u8bed\u8a00\uff0c\u7528\u6765\u67e5\u8be2\u8bb0\u5f55\uff08\u6570\u636e\uff09\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>* \u6ce8\u610f\uff1asql\u8bed\u53e5\u4ee5<strong>;<\/strong>\u7ed3\u5c3e<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"_Toc429465385\"><\/a>4.1 DDL:\u64cd\u4f5c\u6570\u636e\u5e93\u3001\u8868\u3001\u5217\u7b49<\/h2>\n<p>\u4f7f\u7528\u7684\u5173\u952e\u5b57\uff1a<strong>CREATE<\/strong><strong>\u3001 ALTER<\/strong><strong>\u3001 DROP<\/strong><\/p>\n<h3><a name=\"_Toc429465386\"><\/a>* 4.1.1\u64cd\u4f5c\u6570\u636e\u5e93<\/h3>\n<p>\u521b\u5efa<\/p>\n<p>Create database mydb1;<\/p>\n<p>Create database mydb2 character set gbk;<\/p>\n<p>Create database mydb3 character set gbk COLLATE gbk_chinese_ci;<\/p>\n<p>&nbsp;<\/p>\n<p>\u67e5\u8be2<\/p>\n<p>\u67e5\u770b\u5f53\u524d\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e2d\u7684\u6240\u6709\u6570\u636e\u5e93<\/p>\n<p>Show databases;<\/p>\n<p>\u67e5\u770b\u524d\u9762\u521b\u5efa\u7684mydb2\u6570\u636e\u5e93\u7684\u5b9a\u4e49\u4fe1\u606f<\/p>\n<p>Show&nbsp; create&nbsp; database mydb2;<\/p>\n<p>\u5220\u9664\u524d\u9762\u521b\u5efa\u7684mydb3\u6570\u636e\u5e93<\/p>\n<p>Drop database mydb3;<\/p>\n<p>&nbsp;<\/p>\n<p>\u4fee\u6539<\/p>\n<p>\u67e5\u770b\u670d\u52a1\u5668\u4e2d\u7684\u6570\u636e\u5e93\uff0c\u5e76\u628amydb2\u7684\u5b57\u7b26\u96c6\u4fee\u6539\u4e3autf8;<\/p>\n<p>alter database mydb2 character set utf8;<\/p>\n<p>\u5220\u9664<\/p>\n<p>Drop database mydb3;<\/p>\n<p>&nbsp;<\/p>\n<p>* \u5176\u4ed6\uff1a<\/p>\n<p>\u67e5\u770b\u5f53\u524d\u4f7f\u7528\u7684\u6570\u636e\u5e93<\/p>\n<p>Select database();<\/p>\n<p>\u5207\u6362\u6570\u636e\u5e93<\/p>\n<p>Use mydb2;<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"_Toc429465387\"><\/a>* 4.1.2\u64cd\u4f5c\u6570\u636e\u8868<\/h3>\n<p>* \u8bed\u6cd5\uff1a<\/p>\n<p>create table \u8868\u540d(<\/p>\n<p>\u5b57\u6bb51 \u5b57\u6bb5\u7c7b\u578b,<\/p>\n<p>\u5b57\u6bb52 \u5b57\u6bb5\u7c7b\u578b,<\/p>\n<p>&#8230;<\/p>\n<p>\u5b57\u6bb5n \u5b57\u6bb5\u7c7b\u578b<\/p>\n<p>);<\/p>\n<p>&nbsp;<\/p>\n<p>* \u5e38\u7528\u6570\u636e\u7c7b\u578b\uff1a<\/p>\n<p>int\uff1a\u6574\u578b<\/p>\n<p>double\uff1a\u6d6e\u70b9\u578b\uff0c\u4f8b\u5982double(5,2)\u8868\u793a\u6700\u591a5\u4f4d\uff0c\u5176\u4e2d\u5fc5\u987b\u67092\u4f4d\u5c0f\u6570\uff0c\u5373\u6700\u5927\u503c\u4e3a999.99\uff1b<\/p>\n<p>char\uff1a\u56fa\u5b9a\u957f\u5ea6\u5b57\u7b26\u4e32\u7c7b\u578b\uff1b&nbsp;&nbsp;&nbsp; char(10)&nbsp;&nbsp;&nbsp;&nbsp; &#8216;aaa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216;&nbsp; \u536010\u4f4d<\/p>\n<p>varchar\uff1a\u53ef\u53d8\u957f\u5ea6\u5b57\u7b26\u4e32\u7c7b\u578b\uff1b varchar(10)&nbsp; &#8216;aaa&#8217;&nbsp; \u53603\u4e3a<\/p>\n<p>text\uff1a\u5b57\u7b26\u4e32\u7c7b\u578b\uff1b<\/p>\n<p>blob\uff1a\u5b57\u8282\u7c7b\u578b\uff1b<\/p>\n<p>date\uff1a\u65e5\u671f\u7c7b\u578b\uff0c\u683c\u5f0f\u4e3a\uff1ayyyy-MM-dd\uff1b<\/p>\n<p>time\uff1a\u65f6\u95f4\u7c7b\u578b\uff0c\u683c\u5f0f\u4e3a\uff1ahh:mm:ss<\/p>\n<p>timestamp\uff1a\u65f6\u95f4\u6233\u7c7b\u578b yyyy-MM-dd hh:mm:ss&nbsp; \u4f1a\u81ea\u52a8\u8d4b\u503c<\/p>\n<p>datetime:\u65e5\u671f\u65f6\u95f4\u7c7b\u578b yyyy-MM-dd hh:mm:ss<\/p>\n<p>&nbsp;<\/p>\n<p>\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u7684\u6240\u6709\u8868<\/p>\n<p>SHOW TABLES;<\/p>\n<p>\u67e5\u770b\u8868\u7684\u5b57\u6bb5\u4fe1\u606f<\/p>\n<p>DESC employee;<\/p>\n<p>\u5728\u4e0a\u9762\u5458\u5de5\u8868\u7684\u57fa\u672c\u4e0a\u589e\u52a0\u4e00\u4e2aimage\u5217\u3002<\/p>\n<p>ALTER TABLE employee ADD image blob;<\/p>\n<p>\u4fee\u6539job\u5217\uff0c\u4f7f\u5176\u957f\u5ea6\u4e3a60\u3002<\/p>\n<p>ALTER TABLE employee MODIFY job varchar(60);<\/p>\n<p>\u5220\u9664image\u5217,\u4e00\u6b21\u53ea\u80fd\u5220\u4e00\u5217\u3002<\/p>\n<p>ALTER TABLE employee DROP image;<\/p>\n<p>\u8868\u540d\u6539\u4e3auser\u3002<\/p>\n<p>RENAME TABLE employee TO user;<\/p>\n<p>\u67e5\u770b\u8868\u683c\u7684\u521b\u5efa\u7ec6\u8282<\/p>\n<p>SHOW CREATE TABLE user;<\/p>\n<p>\u4fee\u6539\u8868\u7684\u5b57\u7b26\u96c6\u4e3agbk<\/p>\n<p>ALTER TABLE user CHARACTER SET gbk;<\/p>\n<p>\u5217\u540dname\u4fee\u6539\u4e3ausername<\/p>\n<p>ALTER TABLE user CHANGE name username varchar(100);<\/p>\n<p>&nbsp;<\/p>\n<p>\u5220\u9664\u8868<\/p>\n<p>DROP TABLE user ;<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"_Toc429465388\"><\/a>4.2 DML\u64cd\u4f5c(\u91cd\u8981)<\/h2>\n<p>\u67e5\u8be2\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e<\/p>\n<p>SELECT * FROM \u8868\u540d;<\/p>\n<p>&nbsp;<\/p>\n<p>DML\u662f\u5bf9\u8868\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u589e\u3001\u5220\u3001\u6539\u7684\u64cd\u4f5c\u3002\u4e0d\u8981\u4e0eDDL\u6df7\u6dc6\u4e86\u3002<\/p>\n<p>INSERT \u3001UPDATE\u3001 DELETE<\/p>\n<p>&nbsp;<\/p>\n<p>\u5c0f\u77e5\u8bc6\uff1a<\/p>\n<p>\u5728mysql\u4e2d\uff0c\u5b57\u7b26\u4e32\u7c7b\u578b\u548c\u65e5\u671f\u7c7b\u578b\u90fd\u8981\u7528\u5355\u5f15\u53f7\u62ec\u8d77\u6765\u3002<\/p>\n<p>\u7a7a\u503c\uff1anull<\/p>\n<h3><a name=\"_Toc429465389\"><\/a>4.2.1\u63d2\u5165\u64cd\u4f5c\uff1aINSERT:<\/h3>\n<p>\u8bed\u6cd5\uff1a INSERT INTO \u8868\u540d\uff08\u5217\u540d1\uff0c\u5217\u540d2 &#8230;\uff09VALUES(\u5217\u503c1\uff0c\u5217\u503c2&#8230;);<\/p>\n<p>\u6ce8\u610f\uff1a\u5217\u540d\u4e0e\u5217\u503c\u7684\u7c7b\u578b\u3001\u4e2a\u6570\u3001\u987a\u5e8f\u8981\u4e00\u4e00\u5bf9\u5e94\u3002<\/p>\n<p>\u53ef\u4ee5\u628a\u5217\u540d\u5f53\u505ajava\u4e2d\u7684\u5f62\u53c2\uff0c\u628a\u5217\u503c\u5f53\u505a\u5b9e\u53c2\u3002<\/p>\n<p>\u53c2\u4e0d\u8981\u8d85\u51fa\u5217\u5b9a\u4e49\u7684\u957f\u5ea6\u3002<\/p>\n<p>\u5982\u679c\u63d2\u5165\u7a7a\u503c\uff0c\u8bf7\u4f7f\u7528null<\/p>\n<p>\u63d2\u5165\u7684\u65e5\u671f\u548c\u5b57\u7b26\u4e00\u6837\uff0c\u90fd\u4f7f\u7528\u5f15\u53f7\u62ec\u8d77\u6765\u3002<\/p>\n<p>\u7ec3\u4e60 \uff1a<\/p>\n<p>create table emp(<\/p>\n<p>id int,<\/p>\n<p>name varchar(100),<\/p>\n<p>gender varchar(10),<\/p>\n<p>birthday date,<\/p>\n<p>salary float(10,2),<\/p>\n<p>entry_date date,<\/p>\n<p>resume text<\/p>\n<p>);<\/p>\n<p>&nbsp;<\/p>\n<p>INSERT INTO emp(id,name,gender,birthday,salary,entry_date,resume)<\/p>\n<p>VALUES(1,&#8217;zhangsan&#8217;,&#8217;female&#8217;,&#8217;1990-5-10&#8242;,10000,&#8217;2015-5-5-&#8216;,&#8217;good girl&#8217;);<\/p>\n<p>&nbsp;<\/p>\n<p>INSERT INTO emp(id,name,gender,birthday,salary,entry_date,resume)<\/p>\n<p>VALUES(2,&#8217;lisi&#8217;,&#8217;male&#8217;,&#8217;1995-5-10&#8242;,10000,&#8217;2015-5-5&#8242;,&#8217;good boy&#8217;);<\/p>\n<p>&nbsp;<\/p>\n<p>INSERT INTO emp(id,name,gender,birthday,salary,entry_date,resume)<\/p>\n<p>VALUES(3,&#8217;\u4f60\u597d&#8217;,&#8217;male&#8217;,&#8217;1995-5-10&#8242;,10000,&#8217;2015-5-5&#8242;,&#8217;good boy&#8217;);<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5c0f\u77e5\u8bc6\uff1a<\/p>\n<p>\u67e5\u770b\u6570\u636e\u5e93\u7f16\u7801\u7684\u5177\u4f53\u4fe1\u606f<\/p>\n<p>Show variables like \u2018character%\u2019;<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e34\u65f6\u66f4\u6539\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7ed3\u679c\u96c6\u7684\u7f16\u7801<\/p>\n<p>Set character_set_client=gbk;<\/p>\n<p>Set character_set_results=gbk;<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"_Toc429465390\"><\/a>4.2.2 \u4fee\u6539\u64cd\u4f5c UPDATE:<br>\n\u8bed\u6cd5\uff1aUPDATE \u8868\u540d SET \u5217\u540d1=\u5217\u503c1\uff0c\u5217\u540d2=\u5217\u503c2 \u3002\u3002\u3002 WHERE \u5217\u540d=\u503c<\/h3>\n<p>&nbsp;<\/p>\n<p>\u7ec3\u4e60\uff1a<\/p>\n<p>\u5c06\u6240\u6709\u5458\u5de5\u85aa\u6c34\u4fee\u6539\u4e3a5000\u5143\u3002<\/p>\n<p>UPDATE emp SET salary=5000<\/p>\n<p>\u5c06\u59d3\u540d\u4e3a\u2019zs\u2019\u7684\u5458\u5de5\u85aa\u6c34\u4fee\u6539\u4e3a3000\u5143\u3002<\/p>\n<p>UPDATE emp SET salary=3000 WHERE name=\u2019 zhangsan\u2019;<\/p>\n<p>\u5c06\u59d3\u540d\u4e3a\u2019aaa\u2019\u7684\u5458\u5de5\u85aa\u6c34\u4fee\u6539\u4e3a4000\u5143,job\u6539\u4e3accc\u3002<\/p>\n<p>UPDATE emp SET salary=4000,gender=&#8217;female&#8217; WHERE name=&#8217;lisi&#8217;;<\/p>\n<p>\u5c06wu\u7684\u85aa\u6c34\u5728\u539f\u6709\u57fa\u7840\u4e0a\u589e\u52a01000\u5143\u3002<\/p>\n<p>UPDATE emp SET salary=salary+1000 WHERE gender=&#8217;male&#8217;;<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"_Toc429465391\"><\/a>4.2.3 \u5220\u9664\u64cd\u4f5c DELETE:<\/h3>\n<p>\u8bed\u6cd5 \uff1a DELETE \u8868\u540d \u3010WHERE \u5217\u540d=\u503c\u3011<\/p>\n<p>&nbsp;<\/p>\n<p>\u7ec3\u4e60 \uff1a<\/p>\n<p>\u5220\u9664\u8868\u4e2d\u540d\u79f0\u4e3a\u2019zs\u2019\u7684\u8bb0\u5f55\u3002<\/p>\n<p>DELETE FROM emp WHERE name=\u2018zs\u2019;<\/p>\n<p>\u5220\u9664\u8868\u4e2d\u6240\u6709\u8bb0\u5f55\u3002<\/p>\n<p>DELETE FROM emp;<\/p>\n<p>\u4f7f\u7528truncate\u5220\u9664\u8868\u4e2d\u8bb0\u5f55\u3002<\/p>\n<p>TRUNCATE TABLE emp;<\/p>\n<p>&nbsp;<\/p>\n<p>DELETE \u5220\u9664\u8868\u4e2d\u7684\u6570\u636e\uff0c\u8868\u7ed3\u6784\u8fd8\u5728;\u5220\u9664\u540e\u7684\u6570\u636e\u53ef\u4ee5\u627e\u56de<\/p>\n<p>TRUNCATE \u5220\u9664\u662f\u628a\u8868\u76f4\u63a5DROP\u6389\uff0c\u7136\u540e\u518d\u521b\u5efa\u4e00\u4e2a\u540c\u6837\u7684\u65b0\u8868\u3002<\/p>\n<p>\u5220\u9664\u7684\u6570\u636e\u4e0d\u80fd\u627e\u56de\u3002\u6267\u884c\u901f\u5ea6\u6bd4DELETE\u5feb\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"_Toc429465392\"><\/a>4.3 DQL\u64cd\u4f5c<\/h2>\n<p>DQL\u6570\u636e\u67e5\u8be2\u8bed\u8a00 \uff08\u91cd\u8981\uff09<\/p>\n<p>\u6570\u636e\u5e93\u6267\u884cDQL\u8bed\u53e5\u4e0d\u4f1a\u5bf9\u6570\u636e\u8fdb\u884c\u6539\u53d8\uff0c\u800c\u662f\u8ba9\u6570\u636e\u5e93\u53d1\u9001\u7ed3\u679c\u96c6\u7ed9\u5ba2\u6237\u7aef\u3002<\/p>\n<p>\u67e5\u8be2\u8fd4\u56de\u7684\u7ed3\u679c\u96c6\u662f\u4e00\u5f20\u865a\u62df\u8868\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u67e5\u8be2\u5173\u952e\u5b57\uff1aSELECT<\/p>\n<p>\u8bed\u6cd5\uff1a SELECT \u5217\u540d FROM\u8868\u540d<\/p>\n<p>\u3010WHERE &#8211;&gt; BROUP BY &#8211;&gt;HAVING&#8211;&gt; ORDER BY\u3011<\/p>\n<p>&nbsp;<\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<p>SELECT selection_list \/*\u8981\u67e5\u8be2\u7684\u5217\u540d\u79f0*\/<\/p>\n<p>FROM table_list \/*\u8981\u67e5\u8be2\u7684\u8868\u540d\u79f0*\/<\/p>\n<p>WHERE condition \/*\u884c\u6761\u4ef6*\/<\/p>\n<p>GROUP BY grouping_columns \/*\u5bf9\u7ed3\u679c\u5206\u7ec4*\/<\/p>\n<p>HAVING condition \/*\u5206\u7ec4\u540e\u7684\u884c\u6761\u4ef6*\/<\/p>\n<p>ORDER BY sorting_columns \/*\u5bf9\u7ed3\u679c\u5206\u7ec4*\/<\/p>\n<p>LIMIT offset_start, row_count \/*\u7ed3\u679c\u9650\u5b9a*\/<\/p>\n<p>&nbsp;<\/p>\n<p>\u521b\u5efa\u540d\uff1a<\/p>\n<ul>\n<li>\u5b66\u751f\u8868\uff1astu<\/li>\n<\/ul>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"206\"><strong>\u5b57\u6bb5\u540d\u79f0<\/strong><\/td>\n<td width=\"206\"><strong>\u5b57\u6bb5\u7c7b\u578b<\/strong><\/td>\n<td width=\"206\"><strong>\u8bf4\u660e<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>sid<\/strong><\/td>\n<td width=\"206\">char(6)<\/td>\n<td width=\"206\">\u5b66\u751f\u5b66\u53f7<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>sname<\/strong><\/td>\n<td width=\"206\">varchar(50)<\/td>\n<td width=\"206\">\u5b66\u751f\u59d3\u540d<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>age<\/strong><\/td>\n<td width=\"206\">int<\/td>\n<td width=\"206\">\u5b66\u751f\u5e74\u9f84<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>gender<\/strong><\/td>\n<td width=\"206\">varchar(50)<\/td>\n<td width=\"206\">\u5b66\u751f\u6027\u522b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">CREATE TABLE stu (<p><\/p>\n<p>sid&nbsp;&nbsp; CHAR(6),<\/p>\n<p>sname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR(50),<\/p>\n<p>age&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INT,<\/p>\n<p>gender&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR(50)<\/p>\n<p>);<\/p><\/td>\n<\/tr>\n<tr>\n<td width=\"619\">INSERT INTO stu VALUES(&#8216;S_1001&#8217;, &#8216;liuYi&#8217;, 35, &#8216;male&#8217;);<p><\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1002&#8217;, &#8216;chenEr&#8217;, 15, &#8216;female&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1003&#8217;, &#8216;zhangSan&#8217;, 95, &#8216;male&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1004&#8217;, &#8216;liSi&#8217;, 65, &#8216;female&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1005&#8217;, &#8216;wangWu&#8217;, 55, &#8216;male&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1006&#8217;, &#8216;zhaoLiu&#8217;, 75, &#8216;female&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1007&#8217;, &#8216;sunQi&#8217;, 25, &#8216;male&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1008&#8217;, &#8216;zhouBa&#8217;, 45, &#8216;female&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1009&#8217;, &#8216;wuJiu&#8217;, 85, &#8216;male&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1010&#8217;, &#8216;zhengShi&#8217;, 5, &#8216;female&#8217;);<\/p>\n<p>INSERT INTO stu VALUES(&#8216;S_1011&#8217;, &#8216;xxx&#8217;, NULL, NULL);<\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u96c7\u5458\u8868\uff1aemp<\/li>\n<\/ul>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"206\"><strong>\u5b57\u6bb5\u540d\u79f0<\/strong><\/td>\n<td width=\"206\"><strong>\u5b57\u6bb5\u7c7b\u578b<\/strong><\/td>\n<td width=\"206\"><strong>\u8bf4\u660e<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>empno<\/strong><\/td>\n<td width=\"206\">int<\/td>\n<td width=\"206\">\u5458\u5de5\u7f16\u53f7<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>ename<\/strong><\/td>\n<td width=\"206\">varchar(50)<\/td>\n<td width=\"206\">\u5458\u5de5\u59d3\u540d<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>job<\/strong><\/td>\n<td width=\"206\">varchar(50)<\/td>\n<td width=\"206\">\u5458\u5de5\u5de5\u4f5c<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>mgr<\/strong><\/td>\n<td width=\"206\">int<\/td>\n<td width=\"206\">\u9886\u5bfc\u7f16\u53f7<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>hiredate<\/strong><\/td>\n<td width=\"206\">date<\/td>\n<td width=\"206\">\u5165\u804c\u65e5\u671f<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>sal<\/strong><\/td>\n<td width=\"206\">decimal(7,2)<\/td>\n<td width=\"206\">\u6708\u85aa<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>comm<\/strong><\/td>\n<td width=\"206\">decimal(7,2)<\/td>\n<td width=\"206\">\u5956\u91d1<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>deptno<\/strong><\/td>\n<td width=\"206\">int<\/td>\n<td width=\"206\">\u90e8\u5206\u7f16\u53f7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">CREATE TABLE emp(<p><\/p>\n<p>empno&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INT,<\/p>\n<p>ename&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR(50),<\/p>\n<p>job&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VARCHAR(50),<\/p>\n<p>mgr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INT,<\/p>\n<p>hiredate&nbsp;&nbsp; DATE,<\/p>\n<p>sal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DECIMAL(7,2),<\/p>\n<p>comm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; decimal(7,2),<\/p>\n<p>deptno&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INT<\/p>\n<p>) ;<\/p><\/td>\n<\/tr>\n<tr>\n<td width=\"619\">INSERT INTO emp values(7369,&#8217;SMITH&#8217;,&#8217;CLERK&#8217;,7902,&#8217;1980-12-17&#8242;,800,NULL,20);<p><\/p>\n<p>INSERT INTO emp values(7499,&#8217;ALLEN&#8217;,&#8217;SALESMAN&#8217;,7698,&#8217;1981-02-20&#8242;,1600,300,30);<\/p>\n<p>INSERT INTO emp values(7521,&#8217;WARD&#8217;,&#8217;SALESMAN&#8217;,7698,&#8217;1981-02-22&#8242;,1250,500,30);<\/p>\n<p>INSERT INTO emp values(7566,&#8217;JONES&#8217;,&#8217;MANAGER&#8217;,7839,&#8217;1981-04-02&#8242;,2975,NULL,20);<\/p>\n<p>INSERT INTO emp values(7654,&#8217;MARTIN&#8217;,&#8217;SALESMAN&#8217;,7698,&#8217;1981-09-28&#8242;,1250,1400,30);<\/p>\n<p>INSERT INTO emp values(7698,&#8217;BLAKE&#8217;,&#8217;MANAGER&#8217;,7839,&#8217;1981-05-01&#8242;,2850,NULL,30);<\/p>\n<p>INSERT INTO emp values(7782,&#8217;CLARK&#8217;,&#8217;MANAGER&#8217;,7839,&#8217;1981-06-09&#8242;,2450,NULL,10);<\/p>\n<p>INSERT INTO emp values(7788,&#8217;SCOTT&#8217;,&#8217;ANALYST&#8217;,7566,&#8217;1987-04-19&#8242;,3000,NULL,20);<\/p>\n<p>INSERT INTO emp values(7839,&#8217;KING&#8217;,&#8217;PRESIDENT&#8217;,NULL,&#8217;1981-11-17&#8242;,5000,NULL,10);<\/p>\n<p>INSERT INTO emp values(7844,&#8217;TURNER&#8217;,&#8217;SALESMAN&#8217;,7698,&#8217;1981-09-08&#8242;,1500,0,30);<\/p>\n<p>INSERT INTO emp values(7876,&#8217;ADAMS&#8217;,&#8217;CLERK&#8217;,7788,&#8217;1987-05-23&#8242;,1100,NULL,20);<\/p>\n<p>INSERT INTO emp values(7900,&#8217;JAMES&#8217;,&#8217;CLERK&#8217;,7698,&#8217;1981-12-03&#8242;,950,NULL,30);<\/p>\n<p>INSERT INTO emp values(7902,&#8217;FORD&#8217;,&#8217;ANALYST&#8217;,7566,&#8217;1981-12-03&#8242;,3000,NULL,20);<\/p>\n<p>INSERT INTO emp values(7934,&#8217;MILLER&#8217;,&#8217;CLERK&#8217;,7782,&#8217;1982-01-23&#8242;,1300,NULL,10);<\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u90e8\u5206\u8868\uff1adept<\/li>\n<\/ul>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"206\"><strong>\u5b57\u6bb5\u540d\u79f0<\/strong><\/td>\n<td width=\"206\"><strong>\u5b57\u6bb5\u7c7b\u578b<\/strong><\/td>\n<td width=\"206\"><strong>\u8bf4\u660e<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>deptno<\/strong><\/td>\n<td width=\"206\">int<\/td>\n<td width=\"206\">\u90e8\u5206\u7f16\u7801<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>dname<\/strong><\/td>\n<td width=\"206\">varchar(50)<\/td>\n<td width=\"206\">\u90e8\u5206\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td width=\"206\"><strong>loc<\/strong><\/td>\n<td width=\"206\">varchar(50)<\/td>\n<td width=\"206\">\u90e8\u5206\u6240\u5728\u5730\u70b9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">CREATE TABLE dept(<p><\/p>\n<p>deptno&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INT,<\/p>\n<p>dname&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; varchar(14),<\/p>\n<p>loc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; varchar(13)<\/p>\n<p>);<\/p><\/td>\n<\/tr>\n<tr>\n<td width=\"619\">INSERT INTO dept values(10, &#8216;ACCOUNTING&#8217;, &#8216;NEW YORK&#8217;);<p><\/p>\n<p>INSERT INTO dept values(20, &#8216;RESEARCH&#8217;, &#8216;DALLAS&#8217;);<\/p>\n<p>INSERT INTO dept values(30, &#8216;SALES&#8217;, &#8216;CHICAGO&#8217;);<\/p>\n<p>INSERT INTO dept values(40, &#8216;OPERATIONS&#8217;, &#8216;BOSTON&#8217;);<\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h6>1\u3000\u57fa\u7840\u67e5\u8be2<\/h6>\n<p>1.1\u3000\u67e5\u8be2\u6240\u6709\u5217<\/p>\n<p><strong>SELECT * FROM stu;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>1.2\u3000\u67e5\u8be2\u6307\u5b9a\u5217<\/p>\n<p><strong>SELECT sid, sname, age FROM stu;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h6>2\u3000\u6761\u4ef6\u67e5\u8be2<\/h6>\n<p>2.1\u3000\u6761\u4ef6\u67e5\u8be2\u4ecb\u7ecd<\/p>\n<p>\u6761\u4ef6\u67e5\u8be2\u5c31\u662f\u5728\u67e5\u8be2\u65f6\u7ed9\u51faWHERE\u5b50\u53e5\uff0c\u5728WHERE\u5b50\u53e5\u4e2d\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u8fd0\u7b97\u7b26\u53ca\u5173\u952e\u5b57\uff1a<\/p>\n<ul>\n<li>=\u3001!=\u3001&lt;&gt;\u3001&lt;\u3001&lt;=\u3001&gt;\u3001&gt;=\uff1b<\/li>\n<li>BETWEEN\u2026AND\uff1b<\/li>\n<li>IN(set)\uff1b<\/li>\n<li>IS NULL\uff1b<\/li>\n<li>AND\uff1b<\/li>\n<li>OR\uff1b<\/li>\n<li>NOT\uff1b<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>2.2\u3000\u67e5\u8be2\u6027\u522b\u4e3a\u5973\uff0c\u5e76\u4e14\u5e74\u9f8450\u7684\u8bb0\u5f55<\/p>\n<p><strong>SELECT * FROM stu <\/strong><\/p>\n<p><strong>WHERE gender=&#8217;female&#8217; AND ge&lt;50;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>2.3\u3000\u67e5\u8be2\u5b66\u53f7\u4e3aS_1001\uff0c\u6216\u8005\u59d3\u540d\u4e3aliSi\u7684\u8bb0\u5f55<\/p>\n<p><strong>SELECT * FROM stu <\/strong><\/p>\n<p><strong>WHERE sid =&#8217;S_1001&#8242; OR sname=&#8217;liSi&#8217;;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>2.4\u3000\u67e5\u8be2\u5b66\u53f7\u4e3aS_1001\uff0cS_1002\uff0cS_1003\u7684\u8bb0\u5f55<\/p>\n<p><strong>SELECT * FROM stu <\/strong><\/p>\n<p><strong>WHERE sid IN (&#8216;S_1001&#8242;,&#8217;S_1002&#8242;,&#8217;S_1003&#8217;);<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>2.5\u3000\u67e5\u8be2\u5b66\u53f7\u4e0d\u662fS_1001\uff0cS_1002\uff0cS_1003\u7684\u8bb0\u5f55<\/p>\n<p><strong>SELECT * FROM tab_student <\/strong><\/p>\n<p><strong>WHERE s_number NOT IN (&#8216;S_1001&#8242;,&#8217;S_1002&#8242;,&#8217;S_1003&#8217;);<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>2.6\u3000\u67e5\u8be2\u5e74\u9f84\u4e3anull\u7684\u8bb0\u5f55<\/p>\n<p><strong>SELECT * FROM stu<\/strong><\/p>\n<p><strong>WHERE age IS NULL;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>2.7\u3000\u67e5\u8be2\u5e74\u9f84\u572820\u523040\u4e4b\u95f4\u7684\u5b66\u751f\u8bb0\u5f55<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE age&gt;=20 AND age&lt;=40;<\/strong><\/p>\n<p>\u6216\u8005<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu <\/strong><\/p>\n<p><strong>WHERE age BETWEEN 20 AND 40;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>2.8\u3000\u67e5\u8be2\u6027\u522b\u975e\u7537\u7684\u5b66\u751f\u8bb0\u5f55<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE gender!=&#8217;male&#8217;;<\/strong><\/p>\n<p>\u6216\u8005<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE gender&lt;&gt;&#8217;male&#8217;;<\/strong><\/p>\n<p>\u6216\u8005<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE NOT gender=&#8217;male&#8217;;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>2.9\u3000\u67e5\u8be2\u59d3\u540d\u4e0d\u4e3anull\u7684\u5b66\u751f\u8bb0\u5f55<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE NOT sname IS NULL;<\/strong><\/p>\n<p>\u6216\u8005<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE sname IS NOT NULL;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h6>3\u3000\u6a21\u7cca\u67e5\u8be2<\/h6>\n<p>\u5f53\u60f3\u67e5\u8be2\u59d3\u540d\u4e2d\u5305\u542ba\u5b57\u6bcd\u7684\u5b66\u751f\u65f6\u5c31\u9700\u8981\u4f7f\u7528\u6a21\u7cca\u67e5\u8be2\u4e86\u3002\u6a21\u7cca\u67e5\u8be2\u9700\u8981\u4f7f\u7528\u5173\u952e\u5b57LIKE\u3002<\/p>\n<p>\u901a\u914d\u7b26:<\/p>\n<p>_ \u4efb\u610f\u4e00\u4e2a\u5b57\u6bcd<\/p>\n<p>%\uff1a\u4efb\u610f0~n\u4e2a\u5b57\u6bcd<\/p>\n<p>&#8216;\u5f20%&#8217;<\/p>\n<p>3.1\u3000\u67e5\u8be2\u59d3\u540d\u75315\u4e2a\u5b57\u6bcd\u6784\u6210\u7684\u5b66\u751f\u8bb0\u5f55<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE sname LIKE &#8216;_____&#8217;;<\/strong><\/p>\n<p>\u6a21\u7cca\u67e5\u8be2\u5fc5\u987b\u4f7f\u7528LIKE\u5173\u952e\u5b57\u3002\u5176\u4e2d \u201c_\u201d\u5339\u914d\u4efb\u610f\u4e00\u4e2a\u5b57\u6bcd\uff0c5\u4e2a\u201c_\u201d\u8868\u793a5\u4e2a\u4efb\u610f\u5b57\u6bcd\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>3.2\u3000\u67e5\u8be2\u59d3\u540d\u75315\u4e2a\u5b57\u6bcd\u6784\u6210\uff0c\u5e76\u4e14\u7b2c5\u4e2a\u5b57\u6bcd\u4e3a\u201ci\u201d\u7684\u5b66\u751f\u8bb0\u5f55<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE sname LIKE &#8216;____i&#8217;;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>3.3\u3000\u67e5\u8be2\u59d3\u540d\u4ee5\u201cz\u201d\u5f00\u5934\u7684\u5b66\u751f\u8bb0\u5f55<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE sname LIKE &#8216;z%&#8217;;<\/strong><\/p>\n<p>\u5176\u4e2d\u201c%\u201d\u5339\u914d0~n\u4e2a\u4efb\u4f55\u5b57\u6bcd\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>3.4\u3000\u67e5\u8be2\u59d3\u540d\u4e2d\u7b2c2\u4e2a\u5b57\u6bcd\u4e3a\u201ci\u201d\u7684\u5b66\u751f\u8bb0\u5f55<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE sname LIKE &#8216;_i%&#8217;;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>3.5\u3000\u67e5\u8be2\u59d3\u540d\u4e2d\u5305\u542b\u201ca\u201d\u5b57\u6bcd\u7684\u5b66\u751f\u8bb0\u5f55<\/p>\n<p><strong>SELECT * <\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>WHERE sname LIKE &#8216;%a%&#8217;;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h6>4\u3000\u5b57\u6bb5\u63a7\u5236\u67e5\u8be2<\/h6>\n<p>4.1\u3000\u53bb\u9664\u91cd\u590d\u8bb0\u5f55<\/p>\n<p>\u53bb\u9664\u91cd\u590d\u8bb0\u5f55\uff08\u4e24\u884c\u6216\u4e24\u884c\u4ee5\u4e0a\u8bb0\u5f55\u4e2d\u7cfb\u5217\u7684\u4e0a\u7684\u6570\u636e\u90fd\u76f8\u540c\uff09\uff0c\u4f8b\u5982emp\u8868\u4e2dsal\u5b57\u6bb5\u5c31\u5b58\u5728\u76f8\u540c\u7684\u8bb0\u5f55\u3002\u5f53\u53ea\u67e5\u8be2emp\u8868\u7684sal\u5b57\u6bb5\u65f6\uff0c\u90a3\u4e48\u4f1a\u51fa\u73b0\u91cd\u590d\u8bb0\u5f55\uff0c\u90a3\u4e48\u60f3\u53bb\u9664\u91cd\u590d\u8bb0\u5f55\uff0c\u9700\u8981\u4f7f\u7528DISTINCT\uff1a<\/p>\n<p><strong>SELECT DISTINCT sal FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>4.2\u3000\u67e5\u770b\u96c7\u5458\u7684\u6708\u85aa\u4e0e\u4f63\u91d1\u4e4b\u548c<\/p>\n<p>\u56e0\u4e3asal\u548ccomm\u4e24\u5217\u7684\u7c7b\u578b\u90fd\u662f\u6570\u503c\u7c7b\u578b\uff0c\u6240\u4ee5\u53ef\u4ee5\u505a\u52a0\u8fd0\u7b97\u3002\u5982\u679csal\u6216comm\u4e2d\u6709\u4e00\u4e2a\u5b57\u6bb5\u4e0d\u662f\u6570\u503c\u7c7b\u578b\uff0c\u90a3\u4e48\u4f1a\u51fa\u9519\u3002<\/p>\n<p><strong>SELECT *,sal+comm FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>comm\u5217\u6709\u5f88\u591a\u8bb0\u5f55\u7684\u503c\u4e3aNULL\uff0c\u56e0\u4e3a\u4efb\u4f55\u4e1c\u897f\u4e0eNULL\u76f8\u52a0\u7ed3\u679c\u8fd8\u662fNULL\uff0c\u6240\u4ee5\u7ed3\u7b97\u7ed3\u679c\u53ef\u80fd\u4f1a\u51fa\u73b0NULL\u3002\u4e0b\u9762\u4f7f\u7528\u4e86\u628aNULL\u8f6c\u6362\u6210\u6570\u503c0\u7684\u51fd\u6570IFNULL\uff1a<\/p>\n<p><strong>SELECT *,sal+IFNULL(comm,0) FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>4.3\u3000\u7ed9\u5217\u540d\u6dfb\u52a0\u522b\u540d<\/p>\n<p>\u5728\u4e0a\u9762\u67e5\u8be2\u4e2d\u51fa\u73b0\u5217\u540d\u4e3asal+IFNULL(comm,0)\uff0c\u8fd9\u5f88\u4e0d\u7f8e\u89c2\uff0c\u73b0\u5728\u6211\u4eec\u7ed9\u8fd9\u4e00\u5217\u7ed9\u51fa\u4e00\u4e2a\u522b\u540d\uff0c\u4e3atotal\uff1a<\/p>\n<p><strong>SELECT *, sal+IFNULL(comm,0) AS total FROM emp;<\/strong><\/p>\n<p>\u7ed9\u5217\u8d77\u522b\u540d\u65f6\uff0c\u662f\u53ef\u4ee5\u7701\u7565AS\u5173\u952e\u5b57\u7684\uff1a<\/p>\n<p><strong>SELECT *,sal+IFNULL(comm,0) &nbsp;total FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h6>5\u3000\u6392\u5e8f<\/h6>\n<p>5.1\u3000\u67e5\u8be2\u6240\u6709\u5b66\u751f\u8bb0\u5f55\uff0c\u6309\u5e74\u9f84\u5347\u5e8f\u6392\u5e8f<\/p>\n<p><strong>SELECT *<\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>ORDER BY sage ASC;<\/strong><\/p>\n<p>\u6216\u8005<\/p>\n<p><strong>SELECT *<\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>ORDER BY sage;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>5.2\u3000\u67e5\u8be2\u6240\u6709\u5b66\u751f\u8bb0\u5f55\uff0c\u6309\u5e74\u9f84\u964d\u5e8f\u6392\u5e8f<\/p>\n<p><strong>SELECT *<\/strong><\/p>\n<p><strong>FROM stu<\/strong><\/p>\n<p><strong>ORDER BY age DESC;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>5.3\u3000\u67e5\u8be2\u6240\u6709\u96c7\u5458\uff0c\u6309\u6708\u85aa\u964d\u5e8f\u6392\u5e8f\uff0c\u5982\u679c\u6708\u85aa\u76f8\u540c\u65f6\uff0c\u6309\u7f16\u53f7\u5347\u5e8f\u6392\u5e8f<\/p>\n<p><strong>SELECT * FROM emp<\/strong><\/p>\n<p><strong>ORDER BY sal DESC,empno ASC;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h6>6\u3000\u805a\u5408\u51fd\u6570&nbsp; sum avg max min count<\/h6>\n<p>\u805a\u5408\u51fd\u6570\u662f\u7528\u6765\u505a\u7eb5\u5411\u8fd0\u7b97\u7684\u51fd\u6570\uff1a<\/p>\n<ul>\n<li>COUNT()\uff1a\u7edf\u8ba1\u6307\u5b9a\u5217\u4e0d\u4e3aNULL\u7684\u8bb0\u5f55\u884c\u6570\uff1b<\/li>\n<li>MAX()\uff1a\u8ba1\u7b97\u6307\u5b9a\u5217\u7684\u6700\u5927\u503c\uff0c\u5982\u679c\u6307\u5b9a\u5217\u662f\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u90a3\u4e48\u4f7f\u7528\u5b57\u7b26\u4e32\u6392\u5e8f\u8fd0\u7b97\uff1b<\/li>\n<li>MIN()\uff1a\u8ba1\u7b97\u6307\u5b9a\u5217\u7684\u6700\u5c0f\u503c\uff0c\u5982\u679c\u6307\u5b9a\u5217\u662f\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u90a3\u4e48\u4f7f\u7528\u5b57\u7b26\u4e32\u6392\u5e8f\u8fd0\u7b97\uff1b<\/li>\n<li>SUM()\uff1a\u8ba1\u7b97\u6307\u5b9a\u5217\u7684\u6570\u503c\u548c\uff0c\u5982\u679c\u6307\u5b9a\u5217\u7c7b\u578b\u4e0d\u662f\u6570\u503c\u7c7b\u578b\uff0c\u90a3\u4e48\u8ba1\u7b97\u7ed3\u679c\u4e3a0\uff1b<\/li>\n<li>AVG()\uff1a\u8ba1\u7b97\u6307\u5b9a\u5217\u7684\u5e73\u5747\u503c\uff0c\u5982\u679c\u6307\u5b9a\u5217\u7c7b\u578b\u4e0d\u662f\u6570\u503c\u7c7b\u578b\uff0c\u90a3\u4e48\u8ba1\u7b97\u7ed3\u679c\u4e3a0\uff1b<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>6.1\u3000COUNT<\/p>\n<p>\u5f53\u9700\u8981\u7eb5\u5411\u7edf\u8ba1\u65f6\u53ef\u4ee5\u4f7f\u7528COUNT()\u3002<\/p>\n<ul>\n<li>\u67e5\u8be2emp\u8868\u4e2d\u8bb0\u5f55\u6570\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT COUNT(*) AS cnt FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u67e5\u8be2emp\u8868\u4e2d\u6709\u4f63\u91d1\u7684\u4eba\u6570\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT COUNT(comm) cnt FROM emp;<\/strong><\/p>\n<p>\u6ce8\u610f\uff0c\u56e0\u4e3acount()\u51fd\u6570\u4e2d\u7ed9\u51fa\u7684\u662fcomm\u5217\uff0c\u90a3\u4e48\u53ea\u7edf\u8ba1comm\u5217\u975eNULL\u7684\u884c\u6570\u3002<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u67e5\u8be2emp\u8868\u4e2d\u6708\u85aa\u5927\u4e8e2500\u7684\u4eba\u6570\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT COUNT(*) FROM emp<\/strong><\/p>\n<p><strong>WHERE sal &gt; 2500;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u7edf\u8ba1\u6708\u85aa\u4e0e\u4f63\u91d1\u4e4b\u548c\u5927\u4e8e2500\u5143\u7684\u4eba\u6570\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT COUNT(*) AS cnt FROM emp WHERE sal+IFNULL(comm,0) &gt; 2500;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u67e5\u8be2\u6709\u4f63\u91d1\u7684\u4eba\u6570\uff0c\u4ee5\u53ca\u6709\u9886\u5bfc\u7684\u4eba\u6570\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT COUNT(comm), COUNT(mgr) FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>6.2\u3000SUM\u548cAVG<\/p>\n<p>\u5f53\u9700\u8981\u7eb5\u5411\u6c42\u548c\u65f6\u4f7f\u7528sum()\u51fd\u6570\u3002<\/p>\n<ul>\n<li>\u67e5\u8be2\u6240\u6709\u96c7\u5458\u6708\u85aa\u548c\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT SUM(sal) FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u67e5\u8be2\u6240\u6709\u96c7\u5458\u6708\u85aa\u548c\uff0c\u4ee5\u53ca\u6240\u6709\u96c7\u5458\u4f63\u91d1\u548c\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT SUM(sal), SUM(comm) FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u67e5\u8be2\u6240\u6709\u96c7\u5458\u6708\u85aa+\u4f63\u91d1\u548c\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT SUM(sal+IFNULL(comm,0)) FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u7edf\u8ba1\u6240\u6709\u5458\u5de5\u5e73\u5747\u5de5\u8d44\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT AVG(sal) FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>6.3\u3000MAX\u548cMIN<\/p>\n<ul>\n<li>\u67e5\u8be2\u6700\u9ad8\u5de5\u8d44\u548c\u6700\u4f4e\u5de5\u8d44\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT MAX(sal), MIN(sal) FROM emp;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h6>7\u3000\u5206\u7ec4\u67e5\u8be2<\/h6>\n<p>&nbsp;<\/p>\n<p>\u5f53\u9700\u8981\u5206\u7ec4\u67e5\u8be2\u65f6\u9700\u8981\u4f7f\u7528GROUP BY\u5b50\u53e5\uff0c\u4f8b\u5982\u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u7684\u5de5\u8d44\u548c\uff0c\u8fd9\u8bf4\u660e\u8981\u4f7f\u7528\u90e8\u5206\u6765\u5206\u7ec4\u3002<\/p>\n<p>\u6ce8\uff1a\u51e1\u548c\u805a\u5408\u51fd\u6570\u540c\u65f6\u51fa\u73b0\u7684\u5217\u540d\uff0c\u5219\u4e00\u5b9a\u8981\u5199\u5728group by \u4e4b\u540e<\/p>\n<p>7.1\u3000\u5206\u7ec4\u67e5\u8be2<\/p>\n<ul>\n<li>\u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u7684\u90e8\u95e8\u7f16\u53f7\u548c\u6bcf\u4e2a\u90e8\u95e8\u7684\u5de5\u8d44\u548c\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT deptno, SUM(sal)<\/strong><\/p>\n<p><strong>FROM emp<\/strong><\/p>\n<p><strong>GROUP BY deptno;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u7684\u90e8\u95e8\u7f16\u53f7\u4ee5\u53ca\u6bcf\u4e2a\u90e8\u95e8\u7684\u4eba\u6570\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT deptno,COUNT(*)<\/strong><\/p>\n<p><strong>FROM emp<\/strong><\/p>\n<p><strong>GROUP BY deptno;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u67e5\u8be2\u6bcf\u4e2a\u90e8\u95e8\u7684\u90e8\u95e8\u7f16\u53f7\u4ee5\u53ca\u6bcf\u4e2a\u90e8\u95e8\u5de5\u8d44\u5927\u4e8e1500\u7684\u4eba\u6570\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT deptno,COUNT(*)<\/strong><\/p>\n<p><strong>FROM emp<\/strong><\/p>\n<p><strong>WHERE sal&gt;1500<\/strong><\/p>\n<p><strong>GROUP BY deptno;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>7.2\u3000HAVING\u5b50\u53e5<\/p>\n<ul>\n<li>\u67e5\u8be2\u5de5\u8d44\u603b\u548c\u5927\u4e8e9000\u7684\u90e8\u95e8\u7f16\u53f7\u4ee5\u53ca\u5de5\u8d44\u548c\uff1a<\/li>\n<\/ul>\n<p><strong>SELECT deptno, SUM(sal)<\/strong><\/p>\n<p><strong>FROM emp<\/strong><\/p>\n<p><strong>GROUP BY deptno???????<br>\nHAVING SUM(sal) &gt; 9000;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u6ce8\uff1ahaving\u4e0ewhere\u7684\u533a\u522b:<\/p>\n<p>1.having\u662f\u5728\u5206\u7ec4\u540e\u5bf9\u6570\u636e\u8fdb\u884c\u8fc7\u6ee4.<\/p>\n<p>where\u662f\u5728\u5206\u7ec4\u524d\u5bf9\u6570\u636e\u8fdb\u884c\u8fc7\u6ee4<\/p>\n<p>&nbsp;<\/p>\n<p>2.having\u540e\u9762\u53ef\u4ee5\u4f7f\u7528\u5206\u7ec4\u51fd\u6570(\u7edf\u8ba1\u51fd\u6570)<\/p>\n<p>where\u540e\u9762\u4e0d\u53ef\u4ee5\u4f7f\u7528\u5206\u7ec4\u51fd\u6570\u3002<\/p>\n<p>WHERE\u662f\u5bf9\u5206\u7ec4\u524d\u8bb0\u5f55\u7684\u6761\u4ef6\uff0c\u5982\u679c\u67d0\u884c\u8bb0\u5f55\u6ca1\u6709\u6ee1\u8db3WHERE\u5b50\u53e5\u7684\u6761\u4ef6\uff0c\u90a3\u4e48\u8fd9\u884c\u8bb0\u5f55\u4e0d\u4f1a\u53c2\u52a0\u5206\u7ec4\uff1b\u800cHAVING\u662f\u5bf9\u5206\u7ec4\u540e\u6570\u636e\u7684\u7ea6\u675f\u3002<\/p>\n<p>&nbsp;<\/p>\n<h6>8\u3000LIMIT<\/h6>\n<p>LIMIT\u7528\u6765\u9650\u5b9a\u67e5\u8be2\u7ed3\u679c\u7684\u8d77\u59cb\u884c\uff0c\u4ee5\u53ca\u603b\u884c\u6570\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>8.1\u3000\u67e5\u8be25\u884c\u8bb0\u5f55\uff0c\u8d77\u59cb\u884c\u4ece0\u5f00\u59cb<\/p>\n<p><strong>SELECT * FROM emp LIMIT 0, 5;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u6ce8\u610f\uff0c\u8d77\u59cb\u884c\u4ece0\u5f00\u59cb\uff0c\u5373\u7b2c\u4e00\u884c\u5f00\u59cb\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>8.2\u3000\u67e5\u8be210\u884c\u8bb0\u5f55\uff0c\u8d77\u59cb\u884c\u4ece3\u5f00\u59cb<\/p>\n<p><strong>SELECT * FROM emp LIMIT 3, 10;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>8.3\u3000\u5206\u9875\u67e5\u8be2<\/p>\n<p>\u5982\u679c\u4e00\u9875\u8bb0\u5f55\u4e3a10\u6761\uff0c\u5e0c\u671b\u67e5\u770b\u7b2c3\u9875\u8bb0\u5f55\u5e94\u8be5\u600e\u4e48\u67e5\u5462\uff1f<\/p>\n<ul>\n<li>\u7b2c\u4e00\u9875\u8bb0\u5f55\u8d77\u59cb\u884c\u4e3a0\uff0c\u4e00\u5171\u67e5\u8be210\u884c\uff1b<\/li>\n<li>\u7b2c\u4e8c\u9875\u8bb0\u5f55\u8d77\u59cb\u884c\u4e3a10\uff0c\u4e00\u5171\u67e5\u8be210\u884c\uff1b<\/li>\n<li>\u7b2c\u4e09\u9875\u8bb0\u5f55\u8d77\u59cb\u884c\u4e3a20\uff0c\u4e00\u5171\u67e5\u8be210\u884c\uff1b<\/li>\n<\/ul>\n<p>8.3\u3000\u5206\u9875\u67e5\u8be2<\/p>\n<p>\u67e5\u8be2\u8bed\u53e5\u4e66\u5199\u987a\u5e8f\uff1aselect \u2013 from- where- group by- having- order by-limit<\/p>\n<p>\u67e5\u8be2\u8bed\u53e5\u6267\u884c\u987a\u5e8f\uff1afrom &#8211; where -group by &#8211; having &#8211; select &#8211; order by-limit<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1><a name=\"_Toc429465393\"><\/a>\u4e94\u3001\u6570\u636e\u7684\u5b8c\u6574\u6027<\/h1>\n<p>\u4f5c\u7528\uff1a\u4fdd\u8bc1\u7528\u6237\u8f93\u5165\u7684\u6570\u636e\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u4e2d\u662f\u6b63\u786e\u7684\u3002<\/p>\n<p>\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027 = \u5728\u521b\u5efa\u8868\u65f6\u7ed9\u8868\u4e2d\u6dfb\u52a0\u7ea6\u675f<\/p>\n<p>\u5b8c\u6574\u6027\u7684\u5206\u7c7b\uff1a<\/p>\n<p>\u5b9e\u4f53\u5b8c\u6574\u6027:<\/p>\n<p>\u57df\u5b8c\u6574\u6027:<\/p>\n<p>\u5f15\u7528\u5b8c\u6574\u6027:<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"_Toc429465394\"><\/a>1\u3001\u5b9e\u4f53\u5b8c\u6574\u6027<\/h2>\n<p>\u5b9e\u4f53\uff1a\u5373\u8868\u4e2d\u7684\u4e00\u884c(\u4e00\u6761\u8bb0\u5f55)\u4ee3\u8868\u4e00\u4e2a\u5b9e\u4f53\uff08entity\uff09<\/p>\n<p>\u5b9e\u4f53\u5b8c\u6574\u6027\u7684\u4f5c\u7528\uff1a\u6807\u8bc6\u6bcf\u4e00\u884c\u6570\u636e\u4e0d\u91cd\u590d\u3002<\/p>\n<p><strong>\u7ea6\u675f\u7c7b\u578b\uff1a <\/strong><strong>\u4e3b\u952e\u7ea6\u675f\uff08primary key<\/strong><strong>\uff09&nbsp; <\/strong><strong>\u552f\u4e00\u7ea6\u675f(unique)&nbsp; <\/strong><strong>\u81ea\u52a8\u589e\u957f\u5217(auto_increment)<\/strong><\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"_Toc429465395\"><\/a>1.1\u4e3b\u952e\u7ea6\u675f\uff08primary key\uff09<\/h3>\n<p>\u6ce8\uff1a\u6bcf\u4e2a\u8868\u4e2d\u8981\u6709\u4e00\u4e2a\u4e3b\u952e\u3002<\/p>\n<p>\u7279\u70b9\uff1a\u6570\u636e\u552f\u4e00\uff0c\u4e14\u4e0d\u80fd\u4e3anull<\/p>\n<p>\u4f8b\uff1a<\/p>\n<p>\u7b2c\u4e00\u79cd\u6dfb\u52a0\u65b9\u5f0f\uff1a<\/p>\n<p>CREATE TABLE student(<\/p>\n<p>id int primary key,<\/p>\n<p>name varchar(50)<\/p>\n<p>);<\/p>\n<p>\u7b2c\u4e8c\u79cd\u6dfb\u52a0\u65b9\u5f0f\uff1a\u6b64\u79cd\u65b9\u5f0f\u4f18\u52bf\u5728\u4e8e\uff0c\u53ef\u4ee5\u521b\u5efa\u8054\u5408\u4e3b\u952e<\/p>\n<p>CREATE TABLE student(<\/p>\n<p>id int,<\/p>\n<p>name varchar(50),<\/p>\n<p>primary key(id)<\/p>\n<p>);<\/p>\n<p>CREATE TABLE student(<\/p>\n<p>classid int,<\/p>\n<p>stuid int,<\/p>\n<p>name varchar(50),<\/p>\n<p>primary key(classid\uff0cstuid)<\/p>\n<p>);<\/p>\n<p>\u7b2c\u4e09\u79cd\u6dfb\u52a0\u65b9\u5f0f\uff1a<\/p>\n<p>CREATE TABLE student(<\/p>\n<p>id int,<\/p>\n<p>name varchar(50)<\/p>\n<p>);<\/p>\n<p>ALTER TABLE student&nbsp; ADD&nbsp; PRIMARY&nbsp; KEY (id);<\/p>\n<h3><a name=\"_Toc429465396\"><\/a>1.2\u552f\u4e00\u7ea6\u675f(unique)\uff1a<br>\nCREATE TABLE student(<\/h3>\n<p>Id int primary key,<\/p>\n<p>Name varchar(50) unique<\/p>\n<p>);<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"_Toc429465397\"><\/a>1.3\u81ea\u52a8\u589e\u957f\u5217(auto_increment)<\/h3>\n<h3>&nbsp;<a name=\"_Toc429465398\"><\/a>sqlserver\u6570\u636e\u5e93 (identity)&nbsp; oracle\u6570\u636e\u5e93( sequence)<\/h3>\n<p>&nbsp;<\/p>\n<p>\u7ed9\u4e3b\u952e\u6dfb\u52a0\u81ea\u52a8\u589e\u957f\u7684\u6570\u503c\uff0c\u5217\u53ea\u80fd\u662f\u6574\u6570\u7c7b\u578b<\/p>\n<p>CREATE TABLE student(<\/p>\n<p>Id int primary key auto_increment,<\/p>\n<p>Name varchar(50)<\/p>\n<p>);<\/p>\n<p>&nbsp;<\/p>\n<p>INSERT INTO student(name) values(\u2018tom\u2019);<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"_Toc429465399\"><\/a>2\u3001\u57df\u5b8c\u6574\u6027<\/h2>\n<p>\u57df\u5b8c\u6574\u6027\u7684\u4f5c\u7528\uff1a\u9650\u5236\u6b64\u5355\u5143\u683c\u7684\u6570\u636e\u6b63\u786e\uff0c\u4e0d\u5bf9\u7167\u6b64\u5217\u7684\u5176\u5b83\u5355\u5143\u683c\u6bd4\u8f83<\/p>\n<p>\u57df\u4ee3\u8868\u5f53\u524d\u5355\u5143\u683c<\/p>\n<p>\u57df\u5b8c\u6574\u6027\u7ea6\u675f\uff1a\u6570\u636e\u7c7b\u578b \u975e\u7a7a\u7ea6\u675f\uff08not null\uff09 \u9ed8\u8ba4\u503c\u7ea6\u675f(default)<\/p>\n<p>check\u7ea6\u675f\uff08mysql\u4e0d\u652f\u6301\uff09check(sex=&#8217;\u7537&#8217; or&nbsp; sex=&#8217;\u5973&#8217;)<\/p>\n<h3><a name=\"_Toc429465400\"><\/a>1.1 \u6570\u636e\u7c7b\u578b:\uff08\u6570\u503c\u7c7b\u578b\u3001\u65e5\u671f\u7c7b\u578b\u3001\u5b57\u7b26\u4e32\u7c7b\u578b\uff09<\/h3>\n<h3><a name=\"_Toc429465401\"><\/a>1.2 \u975e\u7a7a\u7ea6\u675f\uff1anot null<\/h3>\n<p>CREATE TABLE student(<\/p>\n<p>Id int pirmary key,<\/p>\n<p>Name varchar(50) not null,<\/p>\n<p>Sex varchar(10)<\/p>\n<p>);<\/p>\n<p>&nbsp;<\/p>\n<p>INSERT INTO student values(1,\u2019tom\u2019,null);<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"_Toc429465402\"><\/a>1.3 \u9ed8\u8ba4\u503c\u7ea6\u675f default<\/h3>\n<p>CREATE TABLE student(<\/p>\n<p>Id int pirmary key,<\/p>\n<p>Name varchar(50) not null,<\/p>\n<p>Sex varchar(10) default \u2018\u7537\u2019<\/p>\n<p>);<\/p>\n<p>&nbsp;<\/p>\n<p>insert into student1 values(1,&#8217;tom&#8217;,&#8217;\u5973&#8217;);<\/p>\n<p>insert into student1 values(2,&#8217;jerry&#8217;,default);<\/p>\n<h2><a name=\"_Toc429465403\"><\/a>3\u3001\u5f15\u7528\u5b8c\u6574\u6027\uff08\u53c2\u7167\u5b8c\u6574\u6027\uff09<\/h2>\n<p>\u5916\u952e\u7ea6\u675f\uff1aFOREIGN KEY<\/p>\n<p>\u4f8b\uff1a<\/p>\n<p>CREATE TABLE student(<\/p>\n<p>sid int pirmary key,<\/p>\n<p>name varchar(50) not null,<\/p>\n<p>sex varchar(10) default \u2018\u7537\u2019<\/p>\n<p>);<\/p>\n<p>&nbsp;<\/p>\n<p>create table score(<\/p>\n<p>id int,<\/p>\n<p>score int,<\/p>\n<p>sid int , &#8212; \u5916\u952e\u5217\u7684\u6570\u636e\u7c7b\u578b\u4e00\u5b9a\u8981\u4e0e\u4e3b\u952e\u7684\u7c7b\u578b\u4e00\u81f4<\/p>\n<p>CONSTRAINT fk_score_sid foreign key (sid) references student(id)<\/p>\n<p>);<\/p>\n<p>\u7b2c\u4e8c\u79cd\u6dfb\u52a0\u5916\u952e\u65b9\u5f0f\u3002<\/p>\n<p>ALTER TABLE score1 ADD CONSTRAINT fk_stu_score FOREIGN KEY(sid) REFERENCES stu(id);<\/p>\n<h2><a name=\"_Toc429465404\"><\/a><\/h2>\n<table>\n<tbody>\n<tr>\n<td width=\"71\">\n<table width=\"100%\">\n<tbody>\n<tr>\n<td>&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>4\u3001\u3000\u8868\u4e0e\u8868\u4e4b\u95f4\u7684\u5173\u7cfb<\/h2>\n<ul>\n<li>\u4e00\u5bf9\u4e00\uff1a\u4f8b\u5982t_person\u8868\u548ct_card\u8868\uff0c\u5373\u4eba\u548c\u8eab\u4efd\u8bc1\u3002\u8fd9\u79cd\u60c5\u51b5\u9700\u8981\u627e\u51fa\u4e3b\u4ece\u5173\u7cfb\uff0c\u5373\u8c01\u662f\u4e3b\u8868\uff0c\u8c01\u662f\u4ece\u8868\u3002\u4eba\u53ef\u4ee5\u6ca1\u6709\u8eab\u4efd\u8bc1\uff0c\u4f46\u8eab\u4efd\u8bc1\u5fc5\u987b\u8981\u6709\u4eba\u624d\u884c\uff0c\u6240\u4ee5\u4eba\u662f\u4e3b\u8868\uff0c\u800c\u8eab\u4efd\u8bc1\u662f\u4ece\u8868\u3002\u8bbe\u8ba1\u4ece\u8868\u53ef\u4ee5\u6709\u4e24\u79cd\u65b9\u6848\uff1a<\/li>\n<li>\u5728t_card\u8868\u4e2d\u6dfb\u52a0\u5916\u952e\u5217\uff08\u76f8\u5bf9t_user\u8868\uff09\uff0c\u5e76\u4e14\u7ed9\u5916\u952e\u6dfb\u52a0\u552f\u4e00\u7ea6\u675f\uff1b<\/li>\n<li>\u7ed9t_card\u8868\u7684\u4e3b\u952e\u6dfb\u52a0\u5916\u952e\u7ea6\u675f\uff08\u76f8\u5bf9t_user\u8868\uff09\uff0c\u5373t_card\u8868\u7684\u4e3b\u952e\u4e5f\u662f\u5916\u952e\u3002<\/li>\n<li>\u4e00\u5bf9\u591a\uff08\u591a\u5bf9\u4e00\uff09\uff1a\u6700\u4e3a\u5e38\u89c1\u7684\u5c31\u662f\u4e00\u5bf9\u591a\uff01\u4e00\u5bf9\u591a\u548c\u591a\u5bf9\u4e00\uff0c\u8fd9\u662f\u4ece\u54ea\u4e2a\u89d2\u5ea6\u53bb\u770b\u5f97\u51fa\u6765\u7684\u3002t_user\u548ct_section\u7684\u5173\u7cfb\uff0c\u4ecet_user\u6765\u770b\u5c31\u662f\u4e00\u5bf9\u591a\uff0c\u800c\u4ecet_section\u7684\u89d2\u5ea6\u6765\u770b\u5c31\u662f\u591a\u5bf9\u4e00\uff01\u8fd9\u79cd\u60c5\u51b5\u90fd\u662f\u5728\u591a\u65b9\u521b\u5efa\u5916\u952e\uff01<\/li>\n<li>\u591a\u5bf9\u591a\uff1a\u4f8b\u5982t_stu\u548ct_teacher\u8868\uff0c\u5373\u4e00\u4e2a\u5b66\u751f\u53ef\u4ee5\u6709\u591a\u4e2a\u8001\u5e08\uff0c\u800c\u4e00\u4e2a\u8001\u5e08\u4e5f\u53ef\u4ee5\u6709\u591a\u4e2a\u5b66\u751f\u3002\u8fd9\u79cd\u60c5\u51b5\u901a\u5e38\u9700\u8981\u521b\u5efa\u4e2d\u95f4\u8868\u6765\u5904\u7406\u591a\u5bf9\u591a\u5173\u7cfb\u3002\u4f8b\u5982\u518d\u521b\u5efa\u4e00\u5f20\u8868t_stu_tea\u8868\uff0c\u7ed9\u51fa\u4e24\u4e2a\u5916\u952e\uff0c\u4e00\u4e2a\u76f8\u5bf9t_stu\u8868\u7684\u5916\u952e\uff0c\u53e6\u4e00\u4e2a\u76f8\u5bf9t_teacher\u8868\u7684\u5916\u952e\u3002<\/li>\n<\/ul>\n<h1><a name=\"_Toc429465405\"><\/a>\u516d\u3001\u591a\u8868\u67e5\u8be2<\/h1>\n<p>\u591a\u8868\u67e5\u8be2\u6709\u5982\u4e0b\u51e0\u79cd\uff1a<\/p>\n<ul>\n<li>\u5408\u5e76\u7ed3\u679c\u96c6\uff1bUNION \u3001 UNION ALL<\/li>\n<li>\u8fde\u63a5\u67e5\u8be2<\/li>\n<li>\u5185\u8fde\u63a5 [INNER] JOIN&nbsp; ON<\/li>\n<li>\u5916\u8fde\u63a5 OUTER JOIN ON<\/li>\n<li>\u5de6\u5916\u8fde\u63a5 LEFT [OUTER] JOIN<\/li>\n<li>\u53f3\u5916\u8fde\u63a5 RIGHT [OUTER] JOIN<\/li>\n<li>\u5168\u5916\u8fde\u63a5\uff08MySQL\u4e0d\u652f\u6301\uff09FULL JOIN<\/li>\n<li>\u81ea\u7136\u8fde\u63a5 NATURAL JOIN<\/li>\n<li>\u5b50\u67e5\u8be2<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h6>1\u3000\u5408\u5e76\u7ed3\u679c\u96c6<\/h6>\n<ol>\n<li>\u4f5c\u7528\uff1a\u5408\u5e76\u7ed3\u679c\u96c6\u5c31\u662f\u628a\u4e24\u4e2aselect\u8bed\u53e5\u7684\u67e5\u8be2\u7ed3\u679c\u5408\u5e76\u5230\u4e00\u8d77\uff01<\/li>\n<li>\u5408\u5e76\u7ed3\u679c\u96c6\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a<\/li>\n<\/ol>\n<ul>\n<li>UNION\uff1a\u53bb\u9664\u91cd\u590d\u8bb0\u5f55\uff0c\u4f8b\u5982\uff1aSELECT * FROM t1 UNION SELECT * FROM t2\uff1b<\/li>\n<li>UNION ALL\uff1a\u4e0d\u53bb\u9664\u91cd\u590d\u8bb0\u5f55\uff0c\u4f8b\u5982\uff1aSELECT * FROM t1 UNION ALL SELECT * FROM t2\u3002<\/li>\n<\/ul>\n<ol start=\"3\">\n<li>\u8981\u6c42\uff1a<strong>\u88ab\u5408\u5e76\u7684\u4e24\u4e2a\u7ed3\u679c\uff1a\u5217\u6570\u3001\u5217\u7c7b\u578b\u5fc5\u987b\u76f8\u540c\u3002<\/strong><\/li>\n<\/ol>\n<h6>2\u3000\u8fde\u63a5\u67e5\u8be2 \uff08\u975e\u5e38\u91cd\u8981\uff09<\/h6>\n<p>\u8fde\u63a5\u67e5\u8be2\u5c31\u662f\u6c42\u51fa\u591a\u4e2a\u8868\u7684\u4e58\u79ef\uff0c\u4f8b\u5982t1\u8fde\u63a5t2\uff0c\u90a3\u4e48\u67e5\u8be2\u51fa\u7684\u7ed3\u679c\u5c31\u662ft1*t2\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u8fde\u63a5\u67e5\u8be2\u4f1a\u4ea7\u751f\u7b1b\u5361\u5c14\u79ef\uff0c\u5047\u8bbe\u96c6\u5408A={a,b}\uff0c\u96c6\u5408B={0,1,2}\uff0c\u5219\u4e24\u4e2a\u96c6\u5408\u7684\u7b1b\u5361\u5c14\u79ef\u4e3a{(a,0),(a,1),(a,2),(b,0),(b,1),(b,2)}\u3002\u53ef\u4ee5\u6269\u5c55\u5230\u591a\u4e2a\u96c6\u5408\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u90a3\u4e48\u591a\u8868\u67e5\u8be2\u4ea7\u751f\u8fd9\u6837\u7684\u7ed3\u679c\u5e76\u4e0d\u662f\u6211\u4eec\u60f3\u8981\u7684\uff0c\u90a3\u4e48\u600e\u4e48\u53bb\u9664\u91cd\u590d\u7684\uff0c\u4e0d\u60f3\u8981\u7684\u8bb0\u5f55\u5462\uff0c\u5f53\u7136\u662f\u901a\u8fc7\u6761\u4ef6\u8fc7\u6ee4\u3002\u901a\u5e38\u8981\u67e5\u8be2\u7684\u591a\u4e2a\u8868\u4e4b\u95f4\u90fd\u5b58\u5728\u5173\u8054\u5173\u7cfb\uff0c\u90a3\u4e48\u5c31\u901a\u8fc7\u5173\u8054\u5173\u7cfb\u53bb\u9664\u7b1b\u5361\u5c14\u79ef\u3002<\/p>\n<p>\u4f60\u80fd\u60f3\u50cf\u5230emp\u548cdept\u8868\u8fde\u63a5\u67e5\u8be2\u7684\u7ed3\u679c\u4e48\uff1femp\u4e00\u517114\u884c\u8bb0\u5f55\uff0cdept\u8868\u4e00\u51714\u884c\u8bb0\u5f55\uff0c\u90a3\u4e48\u8fde\u63a5\u540e\u67e5\u8be2\u51fa\u7684\u7ed3\u679c\u662f56\u884c\u8bb0\u5f55\u3002<\/p>\n<p>\u4e5f\u5c31\u4f60\u53ea\u662f\u60f3\u5728\u67e5\u8be2emp\u8868\u7684\u540c\u65f6\uff0c\u628a\u6bcf\u4e2a\u5458\u5de5\u7684\u6240\u5728\u90e8\u95e8\u4fe1\u606f\u663e\u793a\u51fa\u6765\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u4f7f\u7528\u4e3b\u5916\u952e\u6765\u53bb\u9664\u65e0\u7528\u4fe1\u606f\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u4f7f\u7528\u4e3b\u5916\u952e\u5173\u7cfb\u505a\u4e3a\u6761\u4ef6\u6765\u53bb\u9664\u65e0\u7528\u4fe1\u606f<\/strong><\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">SELECT * FROM emp,dept WHERE emp.deptno=dept.deptno;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0a\u9762\u67e5\u8be2\u7ed3\u679c\u4f1a\u628a\u4e24\u5f20\u8868\u7684\u6240\u6709\u5217\u90fd\u67e5\u8be2\u51fa\u6765\uff0c\u4e5f\u8bb8\u4f60\u4e0d\u9700\u8981\u90a3\u4e48\u591a\u5217\uff0c\u8fd9\u65f6\u5c31\u53ef\u4ee5\u6307\u5b9a\u8981\u67e5\u8be2\u7684\u5217\u4e86\u3002<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">SELECT emp.ename,emp.sal,emp.comm,dept.dname<p><\/p>\n<p>FROM emp,dept<\/p>\n<p>WHERE emp.deptno=dept.deptno;<\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u8fd8\u53ef\u4ee5\u4e3a\u8868\u6307\u5b9a\u522b\u540d\uff0c\u7136\u540e\u5728\u5f15\u7528\u5217\u65f6\u4f7f\u7528\u522b\u540d\u5373\u53ef\u3002<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">SELECT e.ename,e.sal,e.comm,d.dname<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>2.1\u3000\u5185\u8fde\u63a5<\/p>\n<p>\u4e0a\u9762\u7684\u8fde\u63a5\u8bed\u53e5\u5c31\u662f\u5185\u8fde\u63a5\uff0c\u4f46\u5b83\u4e0d\u662fSQL\u6807\u51c6\u4e2d\u7684\u67e5\u8be2\u65b9\u5f0f\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u65b9\u8a00\uff01SQL\u6807\u51c6\u7684\u5185\u8fde\u63a5\u4e3a\uff1a<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">SELECT *<p><\/p>\n<p>FROM emp e<\/p>\n<p>INNER JOIN dept d<\/p>\n<p>ON e.deptno=d.deptno;<\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u5185\u8fde\u63a5\u7684\u7279\u70b9\uff1a\u67e5\u8be2\u7ed3\u679c\u5fc5\u987b\u6ee1\u8db3\u6761\u4ef6\u3002\u4f8b\u5982\u6211\u4eec\u5411emp\u8868\u4e2d\u63d2\u5165\u4e00\u6761\u8bb0\u5f55\uff1a<\/p>\n<p>\u5176\u4e2ddeptno\u4e3a50\uff0c\u800c\u5728dept\u8868\u4e2d\u53ea\u670910\u300120\u300130\u300140\u90e8\u95e8\uff0c\u90a3\u4e48\u4e0a\u9762\u7684\u67e5\u8be2\u7ed3\u679c\u4e2d\u5c31\u4e0d\u4f1a\u51fa\u73b0\u201c\u5f20\u4e09\u201d\u8fd9\u6761\u8bb0\u5f55\uff0c\u56e0\u4e3a\u5b83\u4e0d\u80fd\u6ee1\u8db3e.deptno=d.deptno\u8fd9\u4e2a\u6761\u4ef6\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>2.2\u3000\u5916\u8fde\u63a5\uff08\u5de6\u8fde\u63a5\u3001\u53f3\u8fde\u63a5\uff09<\/p>\n<p>\u5916\u8fde\u63a5\u7684\u7279\u70b9\uff1a\u67e5\u8be2\u51fa\u7684\u7ed3\u679c\u5b58\u5728\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u53ef\u80fd\u3002<\/p>\n<p>\u5de6\u8fde\u63a5\uff1a<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">SELECT * FROM emp e<p><\/p>\n<p>LEFT OUTER JOIN dept d<\/p>\n<p>ON e.deptno=d.deptno;<\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u5de6\u8fde\u63a5\u662f\u5148\u67e5\u8be2\u51fa\u5de6\u8868\uff08\u5373\u4ee5\u5de6\u8868\u4e3a\u4e3b\uff09\uff0c\u7136\u540e\u67e5\u8be2\u53f3\u8868\uff0c\u53f3\u8868\u4e2d\u6ee1\u8db3\u6761\u4ef6\u7684\u663e\u793a\u51fa\u6765\uff0c\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u663e\u793aNULL\u3002<\/p>\n<p>\u8fd9\u4e48\u8bf4\u4f60\u53ef\u80fd\u4e0d\u592a\u660e\u767d\uff0c\u6211\u4eec\u8fd8\u662f\u7528\u4e0a\u9762\u7684\u4f8b\u5b50\u6765\u8bf4\u660e\u3002\u5176\u4e2demp\u8868\u4e2d\u201c\u5f20\u4e09\u201d\u8fd9\u6761\u8bb0\u5f55\u4e2d\uff0c\u90e8\u95e8\u7f16\u53f7\u4e3a50\uff0c\u800cdept\u8868\u4e2d\u4e0d\u5b58\u5728\u90e8\u95e8\u7f16\u53f7\u4e3a50\u7684\u8bb0\u5f55\uff0c\u6240\u4ee5\u201c\u5f20\u4e09\u201d\u8fd9\u6761\u8bb0\u5f55\uff0c\u4e0d\u80fd\u6ee1\u8db3e.deptno=d.deptno\u8fd9\u6761\u4ef6\u3002\u4f46\u5728\u5de6\u8fde\u63a5\u4e2d\uff0c\u56e0\u4e3aemp\u8868\u662f\u5de6\u8868\uff0c\u6240\u4ee5\u5de6\u8868\u4e2d\u7684\u8bb0\u5f55\u90fd\u4f1a\u67e5\u8be2\u51fa\u6765\uff0c\u5373\u201c\u5f20\u4e09\u201d\u8fd9\u6761\u8bb0\u5f55\u4e5f\u4f1a\u67e5\u51fa\uff0c\u4f46\u76f8\u5e94\u7684\u53f3\u8868\u90e8\u5206\u663e\u793aNULL\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>2.3\u3000\u53f3\u8fde\u63a5<\/p>\n<p>\u53f3\u8fde\u63a5\u5c31\u662f\u5148\u628a\u53f3\u8868\u4e2d\u6240\u6709\u8bb0\u5f55\u90fd\u67e5\u8be2\u51fa\u6765\uff0c\u7136\u540e\u5de6\u8868\u6ee1\u8db3\u6761\u4ef6\u7684\u663e\u793a\uff0c\u4e0d\u6ee1\u8db3\u663e\u793aNULL\u3002\u4f8b\u5982\u5728dept\u8868\u4e2d\u768440\u90e8\u95e8\u5e76\u4e0d\u5b58\u5728\u5458\u5de5\uff0c\u4f46\u5728\u53f3\u8fde\u63a5\u4e2d\uff0c\u5982\u679cdept\u8868\u4e3a\u53f3\u8868\uff0c\u90a3\u4e48\u8fd8\u662f\u4f1a\u67e5\u51fa40\u90e8\u95e8\uff0c\u4f46\u76f8\u5e94\u7684\u5458\u5de5\u4fe1\u606f\u4e3aNULL\u3002<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">SELECT * FROM emp e<p><\/p>\n<p>RIGHT OUTER JOIN dept d<\/p>\n<p>ON e.deptno=d.deptno;<\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u8fde\u63a5\u67e5\u8be2\u5fc3\u5f97<\/strong>\uff1a<\/p>\n<p>\u8fde\u63a5\u4e0d\u9650\u4e0e\u4e24\u5f20\u8868\uff0c\u8fde\u63a5\u67e5\u8be2\u4e5f\u53ef\u4ee5\u662f\u4e09\u5f20\u3001\u56db\u5f20\uff0c\u751a\u81f3N\u5f20\u8868\u7684\u8fde\u63a5\u67e5\u8be2\u3002\u901a\u5e38\u8fde\u63a5\u67e5\u8be2\u4e0d\u53ef\u80fd\u9700\u8981\u6574\u4e2a\u7b1b\u5361\u5c14\u79ef\uff0c\u800c\u53ea\u662f\u9700\u8981\u5176\u4e2d\u4e00\u90e8\u5206\uff0c\u90a3\u4e48\u8fd9\u65f6\u5c31\u9700\u8981\u4f7f\u7528\u6761\u4ef6\u6765\u53bb\u9664\u4e0d\u9700\u8981\u7684\u8bb0\u5f55\u3002\u8fd9\u4e2a\u6761\u4ef6\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u90fd\u662f\u4f7f\u7528\u4e3b\u5916\u952e\u5173\u7cfb\u53bb\u9664\u3002<\/p>\n<p>\u4e24\u5f20\u8868\u7684\u8fde\u63a5\u67e5\u8be2\u4e00\u5b9a\u6709\u4e00\u4e2a\u4e3b\u5916\u952e\u5173\u7cfb\uff0c\u4e09\u5f20\u8868\u7684\u8fde\u63a5\u67e5\u8be2\u5c31\u4e00\u5b9a\u6709\u4e24\u4e2a\u4e3b\u5916\u952e\u5173\u7cfb\uff0c\u6240\u4ee5\u5728\u5927\u5bb6\u4e0d\u662f\u5f88\u719f\u6089\u8fde\u63a5\u67e5\u8be2\u65f6\uff0c\u9996\u5148\u8981\u5b66\u4f1a\u53bb\u9664\u65e0\u7528\u7b1b\u5361\u5c14\u79ef\uff0c\u90a3\u4e48\u5c31\u662f\u7528\u4e3b\u5916\u952e\u5173\u7cfb\u4f5c\u4e3a\u6761\u4ef6\u6765\u5904\u7406\u3002\u5982\u679c\u4e24\u5f20\u8868\u7684\u67e5\u8be2\uff0c\u90a3\u4e48\u81f3\u5c11\u6709\u4e00\u4e2a\u4e3b\u5916\u952e\u6761\u4ef6\uff0c\u4e09\u5f20\u8868\u8fde\u63a5\u81f3\u5c11\u6709\u4e24\u4e2a\u4e3b\u5916\u952e\u6761\u4ef6<em>\u3002<\/em><\/p>\n<p>&nbsp;<\/p>\n<h6>3\u3000\u81ea\u7136\u8fde\u63a5<\/h6>\n<p>\u5927\u5bb6\u4e5f\u90fd\u77e5\u9053\uff0c\u8fde\u63a5\u67e5\u8be2\u4f1a\u4ea7\u751f\u65e0\u7528\u7b1b\u5361\u5c14\u79ef\uff0c\u6211\u4eec\u901a\u5e38\u4f7f\u7528\u4e3b\u5916\u952e\u5173\u7cfb\u7b49\u5f0f\u6765\u53bb\u9664\u5b83\u3002\u800c\u81ea\u7136\u8fde\u63a5\u65e0\u9700\u4f60\u53bb\u7ed9\u51fa\u4e3b\u5916\u952e\u7b49\u5f0f\uff0c\u5b83\u4f1a\u81ea\u52a8\u627e\u5230\u8fd9\u4e00\u7b49\u5f0f\uff1a<\/p>\n<ul>\n<li>\u4e24\u5f20\u8fde\u63a5\u7684\u8868\u4e2d\u540d\u79f0\u548c\u7c7b\u578b\u5b8c\u5168\u4e00\u81f4\u7684\u5217\u4f5c\u4e3a\u6761\u4ef6\uff0c\u4f8b\u5982emp\u548cdept\u8868\u90fd\u5b58\u5728deptno\u5217\uff0c\u5e76\u4e14\u7c7b\u578b\u4e00\u81f4\uff0c\u6240\u4ee5\u4f1a\u88ab\u81ea\u7136\u8fde\u63a5\u627e\u5230\uff01<\/li>\n<\/ul>\n<p>\u5f53\u7136\u81ea\u7136\u8fde\u63a5\u8fd8\u6709\u5176\u4ed6\u7684\u67e5\u627e\u6761\u4ef6\u7684\u65b9\u5f0f\uff0c\u4f46\u5176\u4ed6\u65b9\u5f0f\u90fd\u53ef\u80fd\u5b58\u5728\u95ee\u9898\uff01<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">SELECT * FROM emp NATURAL JOIN dept;<p><\/p>\n<p>SELECT * FROM emp NATURAL LEFT JOIN dept;<\/p>\n<p>SELECT * FROM emp NATURAL RIGHT JOIN dept;<\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h6>4\u3000\u5b50\u67e5\u8be2\uff08\u975e\u5e38\u91cd\u8981\uff09<\/h6>\n<p>\u4e00\u4e2aselect\u8bed\u53e5\u4e2d\u5305\u542b\u53e6\u4e00\u4e2a\u5b8c\u6574\u7684select\u8bed\u53e5\u3002<\/p>\n<p>\u5b50\u67e5\u8be2\u5c31\u662f\u5d4c\u5957\u67e5\u8be2\uff0c\u5373SELECT\u4e2d\u5305\u542bSELECT\uff0c\u5982\u679c\u4e00\u6761\u8bed\u53e5\u4e2d\u5b58\u5728\u4e24\u4e2a\uff0c\u6216\u4e24\u4e2a\u4ee5\u4e0aSELECT\uff0c\u90a3\u4e48\u5c31\u662f\u5b50\u67e5\u8be2\u8bed\u53e5\u4e86\u3002<\/p>\n<ul>\n<li>\u5b50\u67e5\u8be2\u51fa\u73b0\u7684\u4f4d\u7f6e\uff1a<\/li>\n<li>where\u540e\uff0c\u4f5c\u4e3a\u6761\u4e3a\u88ab\u67e5\u8be2\u7684\u4e00\u6761\u4ef6\u7684\u4e00\u90e8\u5206\uff1b<\/li>\n<li>from\u540e\uff0c\u4f5c\u8868\uff1b<\/li>\n<li>\u5f53\u5b50\u67e5\u8be2\u51fa\u73b0\u5728where\u540e\u4f5c\u4e3a\u6761\u4ef6\u65f6\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u5173\u952e\u5b57\uff1a<\/li>\n<li>any<\/li>\n<li>all<\/li>\n<li>\u5b50\u67e5\u8be2\u7ed3\u679c\u96c6\u7684\u5f62\u5f0f\uff1a<\/li>\n<li>\u5355\u884c\u5355\u5217\uff08\u7528\u4e8e\u6761\u4ef6\uff09<\/li>\n<li>\u5355\u884c\u591a\u5217\uff08\u7528\u4e8e\u6761\u4ef6\uff09<\/li>\n<li>\u591a\u884c\u5355\u5217\uff08\u7528\u4e8e\u6761\u4ef6\uff09<\/li>\n<li>\u591a\u884c\u591a\u5217\uff08\u7528\u4e8e\u8868\uff09<\/li>\n<\/ul>\n<p>\u7ec3\u4e60\uff1a<\/p>\n<ol>\n<li><strong>\u5de5\u8d44\u9ad8\u4e8eJONES<\/strong><strong>\u7684\u5458\u5de5\u3002<\/strong><\/li>\n<\/ol>\n<p>\u5206\u6790\uff1a<\/p>\n<p>\u67e5\u8be2\u6761\u4ef6\uff1a\u5de5\u8d44&gt;JONES\u5de5\u8d44\uff0c\u5176\u4e2dJONES\u5de5\u8d44\u9700\u8981\u4e00\u6761\u5b50\u67e5\u8be2\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u67e5\u8be2JONES\u7684\u5de5\u8d44<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT sal FROM emp WHERE ename=&#8217;JONES&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u67e5\u8be2\u9ad8\u4e8e\u7518\u5b81\u5de5\u8d44\u7684\u5458\u5de5<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT * FROM emp WHERE sal &gt; (${\u7b2c\u4e00\u6b65})<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7ed3\u679c\uff1a<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT * FROM emp WHERE sal &gt; (SELECT sal FROM emp WHERE ename=&#8217;JONES&#8217;)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong>2<\/strong><strong>\u3001\u67e5\u8be2\u4e0eSCOTT<\/strong><strong>\u540c\u4e00\u4e2a\u90e8\u95e8\u7684\u5458\u5de5\u3002<\/strong><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u5b50\u67e5\u8be2\u4f5c\u4e3a\u6761\u4ef6<\/li>\n<li>\u5b50\u67e5\u8be2\u5f62\u5f0f\u4e3a\u5355\u884c\u5355\u5217<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>3<\/strong><strong>\u3001\u5de5\u8d44\u9ad8\u4e8e30<\/strong><strong>\u53f7\u90e8\u95e8\u6240\u6709\u4eba\u7684\u5458\u5de5\u4fe1\u606f<\/strong><\/p>\n<p>\u5206\u6790\uff1a<\/p>\n<p>SELECT * FROM emp WHERE sal&gt;(<\/p>\n<p>SELECT MAX(sal) FROM emp WHERE deptno=30);<\/p>\n<p>&nbsp;<\/p>\n<p>\u67e5\u8be2\u6761\u4ef6\uff1a\u5de5\u8d44\u9ad8\u4e8e30\u90e8\u95e8\u6240\u6709\u4eba\u5de5\u8d44\uff0c\u5176\u4e2d30\u90e8\u95e8\u6240\u6709\u4eba\u5de5\u8d44\u662f\u5b50\u67e5\u8be2\u3002\u9ad8\u4e8e\u6240\u6709\u9700\u8981\u4f7f\u7528all\u5173\u952e\u5b57\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u67e5\u8be230\u90e8\u95e8\u6240\u6709\u4eba\u5de5\u8d44<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT sal FROM emp WHERE deptno=30;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u67e5\u8be2\u9ad8\u4e8e30\u90e8\u95e8\u6240\u6709\u4eba\u5de5\u8d44\u7684\u5458\u5de5\u4fe1\u606f<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT * FROM emp WHERE sal &gt; ALL (${\u7b2c\u4e00\u6b65})<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7ed3\u679c\uff1a<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT * FROM emp WHERE sal &gt; ALL (SELECT sal FROM emp WHERE deptno=30)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u5b50\u67e5\u8be2\u4f5c\u4e3a\u6761\u4ef6<\/li>\n<li>\u5b50\u67e5\u8be2\u5f62\u5f0f\u4e3a\u591a\u884c\u5355\u5217\uff08\u5f53\u5b50\u67e5\u8be2\u7ed3\u679c\u96c6\u5f62\u5f0f\u4e3a\u591a\u884c\u5355\u5217\u65f6\u53ef\u4ee5\u4f7f\u7528ALL\u6216ANY\u5173\u952e\u5b57\uff09<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>4<\/strong><strong>\u3001\u67e5\u8be2\u5de5\u4f5c\u548c\u5de5\u8d44\u4e0eMARTIN<\/strong><strong>\uff08\u9a6c\u4e01\uff09\u5b8c\u5168\u76f8\u540c\u7684\u5458\u5de5\u4fe1\u606f<\/strong><\/p>\n<p>\u5206\u6790\uff1a<\/p>\n<p>\u67e5\u8be2\u6761\u4ef6\uff1a\u5de5\u4f5c\u548c\u5de5\u8d44\u4e0eMARTIN\u5b8c\u5168\u76f8\u540c\uff0c\u8fd9\u662f\u5b50\u67e5\u8be2<\/p>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u67e5\u8be2\u51faMARTIN\u7684\u5de5\u4f5c\u548c\u5de5\u8d44<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT job,sal FROM emp WHERE ename=&#8217;MARTIN&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u67e5\u8be2\u51fa\u4e0eMARTIN\u5de5\u4f5c\u548c\u5de5\u8d44\u76f8\u540c\u7684\u4eba<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT * FROM emp WHERE (job,sal) IN (${\u7b2c\u4e00\u6b65})<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7ed3\u679c\uff1a<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT * FROM emp WHERE (job,sal) IN (SELECT job,sal FROM emp WHERE ename=&#8217;MARTIN&#8217;)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong>5<\/strong><strong>\u3001\u67092<\/strong><strong>\u4e2a\u4ee5\u4e0a\u76f4\u63a5\u4e0b\u5c5e\u7684\u5458\u5de5\u4fe1\u606f<\/strong><\/p>\n<p><strong>&nbsp;<\/strong><\/p>\n<p>SELECT * FROM emp WHERE empno IN(<\/p>\n<p>SELECT mgr FROM emp GROUP BY mgr HAVING COUNT(mgr)&gt;=2);<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u5b50\u67e5\u8be2\u4f5c\u4e3a\u6761\u4ef6<\/li>\n<li>\u5b50\u67e5\u8be2\u5f62\u5f0f\u4e3a\u5355\u884c\u591a\u5217<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>5<\/strong><strong>\u3001\u67e5\u8be2\u5458\u5de5\u7f16\u53f7\u4e3a7788<\/strong><strong>\u7684\u5458\u5de5\u540d\u79f0\u3001\u5458\u5de5\u5de5\u8d44\u3001\u90e8\u95e8\u540d\u79f0\u3001\u90e8\u95e8\u5730\u5740<\/strong><\/p>\n<p><strong>&nbsp;<\/strong><\/p>\n<p>\u5206\u6790\uff1a\uff08\u65e0\u9700\u5b50\u67e5\u8be2\uff09<\/p>\n<p>\u67e5\u8be2\u5217\uff1a\u5458\u5de5\u540d\u79f0\u3001\u5458\u5de5\u5de5\u8d44\u3001\u90e8\u95e8\u540d\u79f0\u3001\u90e8\u95e8\u5730\u5740<\/p>\n<p>\u67e5\u8be2\u8868\uff1aemp\u548cdept\uff0c\u5206\u6790\u5f97\u51fa\uff0c\u4e0d\u9700\u8981\u5916\u8fde\u63a5\uff08\u5916\u8fde\u63a5\u7684\u7279\u6027\uff1a\u67d0\u4e00\u884c\uff08\u6216\u67d0\u4e9b\u884c\uff09\u8bb0\u5f55\u4e0a\u4f1a\u51fa\u73b0\u4e00\u534a\u6709\u503c\uff0c\u4e00\u534a\u4e3aNULL\u503c\uff09<\/p>\n<p>\u6761\u4ef6\uff1a\u5458\u5de5\u7f16\u53f7\u4e3a<strong>7788<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a\u53bb\u9664\u591a\u8868\uff0c\u53ea\u67e5\u4e00\u5f20\u8868\uff0c\u8fd9\u91cc\u53bb\u9664\u90e8\u95e8\u8868\uff0c\u53ea\u67e5\u5458\u5de5\u8868<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT ename, sal FROM emp e WHERE empno=<strong>7788<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a\u8ba9\u7b2c\u4e00\u6b65\u4e0edept\u505a\u5185\u8fde\u63a5\u67e5\u8be2\uff0c\u6dfb\u52a0\u4e3b\u5916\u952e\u6761\u4ef6\u53bb\u9664\u65e0\u7528\u7b1b\u5361\u5c14\u79ef<\/p>\n<table width=\"592\">\n<tbody>\n<tr>\n<td width=\"592\">SELECT e.ename, e.sal, d.dname, d.loc<p><\/p>\n<p>FROM emp e, dept d<\/p>\n<p>WHERE e.deptno=d.deptno AND empno=<strong>7788<\/strong><\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u4e8c\u6b65\u4e2d\u7684dept\u8868\u8868\u793a\u6240\u6709\u884c\u6240\u6709\u5217\u7684\u4e00\u5f20\u5b8c\u6574\u7684\u8868\uff0c\u8fd9\u91cc\u53ef\u4ee5\u628adept\u66ff\u6362\u6210\u6240\u6709\u884c\uff0c\u4f46\u53ea\u6709dname\u548cloc\u5217\u7684\u8868\uff0c\u8fd9\u9700\u8981\u5b50\u67e5\u8be2\u3002<\/p>\n<p>\u7b2c\u4e09\u6b65\uff1a\u67e5\u8be2dept\u8868\u4e2ddname\u548cloc\u4e24\u5217\uff0c\u56e0\u4e3adeptno\u4f1a\u88ab\u4f5c\u4e3a\u6761\u4ef6\uff0c\u7528\u6765\u53bb\u9664\u65e0\u7528\u7b1b\u5361\u5c14\u79ef\uff0c\u6240\u4ee5\u9700\u8981\u67e5\u8be2\u5b83\u3002<\/p>\n<table width=\"591\">\n<tbody>\n<tr>\n<td width=\"591\">SELECT dname,loc,deptno FROM dept;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>\u7b2c\u56db\u6b65\uff1a\u66ff\u6362\u7b2c\u4e8c\u6b65\u4e2d\u7684dept<\/p>\n<table width=\"591\">\n<tbody>\n<tr>\n<td width=\"591\">SELECT e.ename, e.sal, d.dname, d.loc<p><\/p>\n<p>FROM emp e, (SELECT dname,loc,deptno FROM dept) d<\/p>\n<p>WHERE e.deptno=d.deptno AND e.empno=<strong>7788<\/strong><\/p><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ul>\n<li>\u5b50\u67e5\u8be2\u4f5c\u4e3a\u8868<\/li>\n<li>\u5b50\u67e5\u8be2\u5f62\u5f0f\u4e3a\u591a\u884c\u591a\u5217<\/li>\n<\/ul>\n<h6>6\u3001\u81ea\u8fde\u63a5:\u81ea\u5df1\u8fde\u63a5\u81ea\u5df1\uff0c\u8d77\u522b\u540d<\/h6>\n<p>\u6c427369\u5458\u5de5\u7f16\u53f7\u3001\u59d3\u540d\u3001\u7ecf\u7406\u7f16\u53f7\u548c\u7ecf\u7406\u59d3\u540d<\/p>\n<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/strong>SELECT e1.empno , e1.ename,e2.mgr,e2.ename<\/p>\n<p>FROM emp e1, emp e2<\/p>\n<p>WHERE e1.mgr = e2.empno AND e1.empno = 7369;<\/p>\n<p>&nbsp;<\/p>\n<p>\u7ec3\u4e60\uff1a<\/p>\n<p>\u6c42\u5404\u4e2a\u90e8\u95e8\u85aa\u6c34\u6700\u9ad8\u7684\u5458\u5de5\u6240\u6709\u4fe1\u606f<\/p>\n<p>select e.* from emp e,<\/p>\n<p>&#8211;\u90e8\u95e8\u6700\u9ad8\u5de5\u8d44<\/p>\n<p>(select max(sal) maxsal,deptno from emp<\/p>\n<p>group by deptno) a<\/p>\n<p>where e.deptno = a.deptno<\/p>\n<p>and e.sal =a.maxsal<\/p>\n<p>&nbsp;<\/p>\n<h1><a name=\"_Toc429465406\"><\/a>\u4e03\u3001MySQL\u4e2d\u7684\u51fd\u6570<\/h1>\n<h1><a name=\"_Toc429465407\"><\/a>\u516b\u3001MySQL\u6570\u636e\u5e93\u7684\u5907\u4efd\u4e0e\u6062\u590d<\/h1>\n<h2><a name=\"_Toc429465408\"><\/a>1\u3000\u751f\u6210SQL\u811a\u672c&nbsp; \u5bfc\u51fa\u6570\u636e<\/h2>\n<p>\u5728\u63a7\u5236\u53f0\u4f7f\u7528mysqldump\u547d\u4ee4\u53ef\u4ee5\u7528\u6765\u751f\u6210\u6307\u5b9a\u6570\u636e\u5e93\u7684\u811a\u672c\u6587\u672c\uff0c\u4f46\u8981\u6ce8\u610f\uff0c\u811a\u672c\u6587\u672c\u4e2d\u53ea\u5305\u542b\u6570\u636e\u5e93\u7684\u5185\u5bb9\uff0c\u800c\u4e0d\u4f1a\u5b58\u5728\u521b\u5efa\u6570\u636e\u5e93\u7684\u8bed\u53e5\uff01\u6240\u4ee5\u5728\u6062\u590d\u6570\u636e\u65f6\uff0c\u8fd8\u9700\u8981\u81ea\u5df2\u624b\u52a8\u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u4e4b\u540e\u518d\u53bb\u6062\u590d\u6570\u636e\u3002<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">\u3000\u3000mysqldump \u2013u\u7528\u6237\u540d \u2013p\u5bc6\u7801 \u6570\u636e\u5e93\u540d&gt;\u751f\u6210\u7684\u811a\u672c\u6587\u4ef6\u8def\u5f84<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u73b0\u5728\u53ef\u4ee5\u5728C\u76d8\u4e0b\u627e\u5230mydb1.sql\u6587\u4ef6\u4e86\uff01<\/p>\n<p>\u6ce8\u610f\uff0cmysqldump\u547d\u4ee4\u662f\u5728Windows\u63a7\u5236\u53f0\u4e0b\u6267\u884c\uff0c\u65e0\u9700\u767b\u5f55mysql\uff01\uff01\uff01<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"_Toc429465409\"><\/a>2\u3000\u6267\u884cSQL\u811a\u672c \u6062\u590d\u6570\u636e<\/h2>\n<p><strong>\u524d\u63d0\uff1a\u5fc5\u987b\u5148\u521b\u5efa\u6570\u636e\u5e93\u540d<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u6267\u884cSQL<\/strong><strong>\u811a\u672c\u9700\u8981\u767b\u5f55mysql<\/strong>\uff0c\u7136\u540e\u8fdb\u5165\u6307\u5b9a\u6570\u636e\u5e93\uff0c\u624d\u53ef\u4ee5\u6267\u884cSQL\u811a\u672c\uff01\uff01\uff01<\/p>\n<p>\u6267\u884cSQL\u811a\u672c\u4e0d\u53ea\u662f\u7528\u6765\u6062\u590d\u6570\u636e\u5e93\uff0c\u4e5f\u53ef\u4ee5\u5728\u5e73\u65f6\u7f16\u5199SQL\u811a\u672c\uff0c\u7136\u540e\u4f7f\u7528\u6267\u884cSQL \u811a\u672c\u6765\u64cd\u4f5c\u6570\u636e\u5e93\uff01\u5927\u5bb6\u90fd\u77e5\u9053\uff0c\u5728\u9ed1\u5c4f\u4e0b\u7f16\u5199SQL\u8bed\u53e5\u65f6\uff0c\u5c31\u7b97\u53d1\u73b0\u4e86\u9519\u8bef\uff0c\u53ef\u80fd\u4e5f\u4e0d\u80fd\u4fee\u6539\u4e86\u3002\u6240\u4ee5\u6211\u5efa\u8bae\u5927\u5bb6\u4f7f\u7528\u811a\u672c\u6587\u4ef6\u6765\u7f16\u5199SQL\u4ee3\u7801\uff0c\u7136\u540e\u6267\u884c\u4e4b\uff01<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">SOURCE C:\\mydb1.sql<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u6ce8\u610f\uff0c\u5728\u6267\u884c\u811a\u672c\u65f6\u9700\u8981\u5148\u884c\u6838\u67e5\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u7684\u8868\u662f\u5426\u4e0e\u811a\u672c\u6587\u4ef6\u4e2d\u7684\u8bed\u53e5\u6709\u51b2\u7a81\uff01\u4f8b\u5982\u5728\u811a\u672c\u6587\u4ef6\u4e2d\u5b58\u5728create table a\u7684\u8bed\u53e5\uff0c\u800c\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u5df2\u7ecf\u5b58\u5728\u4e86a\u8868\uff0c\u90a3\u4e48\u5c31\u4f1a\u51fa\u9519\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u65b9\u5f0f\u6765\u6267\u884c\u811a\u672c\u6587\u4ef6\uff1a<\/p>\n<p>mysql -uroot -p123 mydb1&lt;c:\\mydb1.sql<\/p>\n<table width=\"619\">\n<tbody>\n<tr>\n<td width=\"619\">mysql \u2013u\u7528\u6237\u540d \u2013p\u5bc6\u7801 \u6570\u636e\u5e93&lt;\u8981\u6267\u884c\u811a\u672c\u6587\u4ef6\u8def\u5f84<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong>\u8fd9\u79cd\u65b9\u5f0f\u65e0\u9700\u767b\u5f55mysql<\/strong><strong>\uff01<\/strong><\/p>\n<p><strong>&nbsp;<\/strong><\/p>\n<p><strong>\u6ce8\u610f\uff1a\u5728CMD<\/strong><strong>\u4e0b <\/strong><strong>\u547d\u4ee4\u4e0d\u80fd\u52a0;<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u611f\u89c9\u4ee5\u4e0b\u6392\u7248\u4e0d\u9002\u5408\u9605\u8bfb \u8bf7\u4e0b\u8f7dword\u7248\u672c(\u63d0\u53d6\u7801:med0r) \u76ee\u5f55 \u4e00\u3001\u6570\u636e\u5e93\u6982\u8ff0&#8230;&#038;#8 [&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":[62],"class_list":["post-151","post","type-post","status-publish","format-standard","hentry","category-jishu","tag-zongjie"],"_links":{"self":[{"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=\/wp\/v2\/posts\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=151"}],"version-history":[{"count":0,"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=\/wp\/v2\/posts\/151\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.tongyunli.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}