{"id":152015,"date":"2024-11-01T19:23:53","date_gmt":"2024-11-01T11:23:53","guid":{"rendered":"https:\/\/server.hk\/cnblog\/152015\/"},"modified":"2024-11-01T19:23:54","modified_gmt":"2024-11-01T11:23:54","slug":"%e6%af%94sql%e5%bf%ab%ef%bc%9f%e9%80%99%e5%80%8b%e6%95%b8%e6%93%9a%e5%ba%ab%e7%a5%9e%e5%99%a8%e5%bc%b7%e7%9a%84%e9%9b%a2%e8%ad%9c%ef%bc%81","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/152015\/","title":{"rendered":"\u6bd4SQL\u5feb\uff1f\u9019\u500b\u6578\u64da\u5eab\u795e\u5668\u5f37\u7684\u96e2\u8b5c\uff01"},"content":{"rendered":"<h1 id=\"%e6%af%94sql%e5%bf%ab%ef%bc%9f%e9%80%99%e5%80%8b%e6%95%b8%e6%93%9a%e5%ba%ab%e7%a5%9e%e5%99%a8%e5%bc%b7%e7%9a%84%e9%9b%a2%e8%ad%9c%ef%bc%81-pPaGpGjadc\">\u6bd4SQL\u5feb\uff1f\u9019\u500b\u6578\u64da\u5eab\u795e\u5668\u5f37\u7684\u96e2\u8b5c\uff01<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u6027\u80fd\u5c0d\u65bc\u61c9\u7528\u7a0b\u5e8f\u7684\u6548\u7387\u81f3\u95dc\u91cd\u8981\u3002\u50b3\u7d71\u7684\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u5982MySQL\u548cPostgreSQL\u96d6\u7136\u5728\u8a31\u591a\u5834\u666f\u4e2d\u8868\u73fe\u826f\u597d\uff0c\u4f46\u96a8\u8457\u6578\u64da\u91cf\u7684\u589e\u9577\u548c\u67e5\u8a62\u9700\u6c42\u7684\u8907\u96dc\u5316\uff0c\u9019\u4e9b\u6578\u64da\u5eab\u7684\u6027\u80fd\u53ef\u80fd\u6703\u53d7\u5230\u9650\u5236\u3002\u9019\u6642\uff0c\u4e00\u4e9b\u65b0\u8208\u7684\u6578\u64da\u5eab\u6280\u8853\u958b\u59cb\u53d7\u5230\u95dc\u6ce8\uff0c\u5176\u4e2d\u4e00\u500b\u5f15\u4eba\u6ce8\u76ee\u7684\u9078\u64c7\u4fbf\u662fNoSQL\u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"nosql%e6%95%b8%e6%93%9a%e5%ba%ab%e7%9a%84%e5%b4%9b%e8%b5%b7-pPaGpGjadc\">NoSQL\u6578\u64da\u5eab\u7684\u5d1b\u8d77<\/h2>\n<p>NoSQL\u6578\u64da\u5eab\u662f\u4e00\u7a2e\u975e\u95dc\u4fc2\u578b\u6578\u64da\u5eab\uff0c\u65e8\u5728\u89e3\u6c7a\u50b3\u7d71SQL\u6578\u64da\u5eab\u5728\u8655\u7406\u5927\u898f\u6a21\u6578\u64da\u6642\u7684\u74f6\u9838\u3002\u9019\u985e\u6578\u64da\u5eab\u901a\u5e38\u5177\u5099\u9ad8\u53ef\u64f4\u5c55\u6027\u548c\u9748\u6d3b\u7684\u6578\u64da\u6a21\u578b\uff0c\u80fd\u5920\u66f4\u597d\u5730\u61c9\u5c0d\u4e0d\u65b7\u8b8a\u5316\u7684\u6578\u64da\u9700\u6c42\u3002\u5e38\u898b\u7684NoSQL\u6578\u64da\u5eab\u5305\u62ecMongoDB\u3001Cassandra\u548cRedis\u7b49\u3002<\/p>\n<h3 id=\"mongodb%ef%bc%9a%e6%96%87%e6%aa%94%e5%b0%8e%e5%90%91%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab-pPaGpGjadc\">MongoDB\uff1a\u6587\u6a94\u5c0e\u5411\u7684\u6578\u64da\u5eab<\/h3>\n<p>MongoDB\u662f\u4e00\u7a2e\u6587\u6a94\u5c0e\u5411\u7684NoSQL\u6578\u64da\u5eab\uff0c\u4f7f\u7528BSON\uff08\u985e\u4f3cJSON\u7684\u683c\u5f0f\uff09\u4f86\u5b58\u5132\u6578\u64da\u3002\u9019\u4f7f\u5f97MongoDB\u5728\u8655\u7406\u7d50\u69cb\u5316\u548c\u534a\u7d50\u69cb\u5316\u6578\u64da\u6642\u975e\u5e38\u9748\u6d3b\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684MongoDB\u67e5\u8a62\u793a\u4f8b\uff1a<\/p>\n<pre><code>db.users.find({ age: { $gt: 18 } })<\/code><\/pre>\n<p>\u9019\u500b\u67e5\u8a62\u5c07\u8fd4\u56de\u6240\u6709\u5e74\u9f61\u5927\u65bc18\u7684\u7528\u6236\u3002\u7531\u65bcMongoDB\u7684\u8a2d\u8a08\uff0c\u9019\u985e\u67e5\u8a62\u7684\u57f7\u884c\u901f\u5ea6\u901a\u5e38\u6bd4\u50b3\u7d71SQL\u67e5\u8a62\u5feb\uff0c\u7279\u5225\u662f\u5728\u8655\u7406\u5927\u91cf\u6578\u64da\u6642\u3002<\/p>\n<h3 id=\"cassandra%ef%bc%9a%e5%88%86%e4%bd%88%e5%bc%8f%e6%95%b8%e6%93%9a%e5%ba%ab-pPaGpGjadc\">Cassandra\uff1a\u5206\u4f48\u5f0f\u6578\u64da\u5eab<\/h3>\n<p>Cassandra\u662f\u4e00\u7a2e\u5206\u4f48\u5f0fNoSQL\u6578\u64da\u5eab\uff0c\u5c08\u70ba\u8655\u7406\u5927\u91cf\u6578\u64da\u800c\u8a2d\u8a08\u3002\u5b83\u7684\u67b6\u69cb\u5141\u8a31\u6578\u64da\u5728\u591a\u500b\u4f3a\u670d\u5668\u4e4b\u9593\u5206\u4f48\uff0c\u5f9e\u800c\u63d0\u9ad8\u4e86\u53ef\u7528\u6027\u548c\u5bb9\u932f\u6027\u3002Cassandra\u7684\u67e5\u8a62\u8a9e\u8a00CQL\uff08Cassandra Query Language\uff09\u985e\u4f3c\u65bcSQL\uff0c\u4f46\u66f4\u9069\u5408\u65bc\u5927\u898f\u6a21\u6578\u64da\u7684\u64cd\u4f5c\u3002\u4ee5\u4e0b\u662f\u4e00\u500bCassandra\u67e5\u8a62\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>SELECT * FROM users WHERE age &gt; 18;<\/code><\/pre>\n<p>\u9019\u500b\u67e5\u8a62\u540c\u6a23\u80fd\u5920\u5feb\u901f\u8fd4\u56de\u7b26\u5408\u689d\u4ef6\u7684\u7528\u6236\uff0c\u4e26\u4e14\u5728\u6578\u64da\u91cf\u589e\u9577\u6642\uff0cCassandra\u7684\u6027\u80fd\u4f9d\u7136\u7a69\u5b9a\u3002<\/p>\n<h3 id=\"redis%ef%bc%9a%e5%85%a7%e5%ad%98%e6%95%b8%e6%93%9a%e5%ba%ab-pPaGpGjadc\">Redis\uff1a\u5167\u5b58\u6578\u64da\u5eab<\/h3>\n<p>Redis\u662f\u4e00\u7a2e\u9ad8\u6027\u80fd\u7684\u5167\u5b58\u6578\u64da\u5eab\uff0c\u5e38\u7528\u65bc\u9700\u8981\u5feb\u901f\u8b80\u53d6\u548c\u5beb\u5165\u7684\u5834\u666f\u3002\u7531\u65bc\u6578\u64da\u5b58\u5132\u5728\u5167\u5b58\u4e2d\uff0cRedis\u7684\u8b80\u53d6\u901f\u5ea6\u6975\u5feb\uff0c\u9069\u5408\u7528\u65bc\u7de9\u5b58\u3001\u5373\u6642\u5206\u6790\u7b49\u61c9\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u500bRedis\u7684\u64cd\u4f5c\u793a\u4f8b\uff1a<\/p>\n<pre><code>SET user:1000 \"John Doe\"<\/code><\/pre>\n<pre><code>GET user:1000<\/code><\/pre>\n<p>\u9019\u6bb5\u4ee3\u78bc\u5c55\u793a\u4e86\u5982\u4f55\u5728Redis\u4e2d\u8a2d\u7f6e\u548c\u7372\u53d6\u7528\u6236\u6578\u64da\uff0c\u64cd\u4f5c\u7684\u901f\u5ea6\u5e7e\u4e4e\u662f\u77ac\u6642\u7684\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-pPaGpGjadc\">\u7d50\u8ad6<\/h2>\n<p>\u96a8\u8457\u6578\u64da\u91cf\u7684\u6fc0\u589e\u548c\u61c9\u7528\u9700\u6c42\u7684\u591a\u6a23\u5316\uff0cNoSQL\u6578\u64da\u5eab\u63d0\u4f9b\u4e86\u6bd4\u50b3\u7d71SQL\u6578\u64da\u5eab\u66f4\u9ad8\u7684\u6027\u80fd\u548c\u9748\u6d3b\u6027\u3002\u7121\u8ad6\u662fMongoDB\u7684\u6587\u6a94\u5c0e\u5411\u3001Cassandra\u7684\u5206\u4f48\u5f0f\u67b6\u69cb\uff0c\u9084\u662fRedis\u7684\u5167\u5b58\u5b58\u5132\uff0c\u9019\u4e9b\u6280\u8853\u90fd\u5728\u4e0d\u540c\u7684\u5834\u666f\u4e2d\u5c55\u73fe\u4e86\u5176\u5f37\u5927\u7684\u80fd\u529b\u3002<\/p>\n<p>\u5c0d\u65bc\u9700\u8981\u9ad8\u6027\u80fd\u6578\u64da\u8655\u7406\u7684\u4f01\u696d\u4f86\u8aaa\uff0c\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u5eab\u6280\u8853\u81f3\u95dc\u91cd\u8981\u3002\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0c\u672a\u4f86\u53ef\u80fd\u6703\u51fa\u73fe\u66f4\u591a\u5275\u65b0\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u9032\u4e00\u6b65\u63d0\u5347\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u6548\u7387\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u4f86\u90e8\u7f72\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\uff0c\u4eab\u53d7\u66f4\u5feb\u7684\u6578\u64da\u8655\u7406\u901f\u5ea6\u548c\u66f4\u9ad8\u7684\u53ef\u7528\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u6bd4SQL\u66f4\u5feb\u7684\u6578\u64da\u5eab\u795e\u5668\uff0c\u63ed\u793a\u5176\u5f37\u5927\u6027\u80fd\u548c\u512a\u52e2\uff0c\u8b93\u6578\u64da\u8655\u7406\u6548\u7387\u5927\u5e45\u63d0\u5347\uff01<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-152015","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=152015"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152015\/revisions"}],"predecessor-version":[{"id":152016,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152015\/revisions\/152016"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=152015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=152015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=152015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}