{"id":5367,"date":"2024-11-14T12:52:25","date_gmt":"2024-11-14T04:52:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5367\/"},"modified":"2024-11-14T12:52:25","modified_gmt":"2024-11-14T04:52:25","slug":"mongodb%e5%91%bd%e4%bb%a4%e6%80%8e%e4%b9%88%e8%ae%be%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5367\/","title":{"rendered":"mongodb\u547d\u4ee4\u600e\u4e48\u8bbe\u7f6e"},"content":{"rendered":"<blockquote><p>\n  \u8981\u8bbe\u7f6emongodb\u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\uff08use\u548cdb.createcollection()\uff09\u6216mongo shell\uff08mongo\u3001use\u548cdb.createcollection()\uff09\u3002\u5176\u4ed6\u8bbe\u7f6e\u9009\u9879\u5305\u62ec\u67e5\u770b\u6570\u636e\u5e93\uff08show dbs\uff09\u3001\u67e5\u770b\u96c6\u5408\uff08show collections\uff09\u3001\u5220\u9664\u6570\u636e\u5e93\uff08db.dropdatabase()\uff09\u3001\u5220\u9664\u96c6\u5408\uff08db..drop()\uff09\u3001\u63d2\u5165\u6587\u6863\uff08db.\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/28\/2024052802091755394.jpg\" class=\"aligncenter\" title=\"mongodb\u547d\u4ee4\u600e\u4e48\u8bbe\u7f6e\u63d2\u56fe\" alt=\"mongodb\u547d\u4ee4\u600e\u4e48\u8bbe\u7f6e\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 MongoDB \u547d\u4ee4\u8bbe\u7f6e\u6570\u636e\u5e93<\/strong><\/p>\n<p><strong>\u76f4\u63a5\u547d\u4ee4\u884c\u8bbe\u7f6e<\/strong><\/p>\n<ul>\n<li> <strong>\u521b\u5efa\u6570\u636e\u5e93\uff1a<\/strong> use <\/li>\n<li> <strong>\u521b\u5efa\u96c6\u5408\uff08\u8868\uff09\uff1a<\/strong> db.createCollection( ) <\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528 mongo Shell<\/strong><\/p>\n<ol>\n<li> <strong>\u8fde\u63a5 MongoDB\uff1a<\/strong> mongo<\/li>\n<li> <strong>\u5207\u6362\u6570\u636e\u5e93\uff1a<\/strong> use <\/li>\n<li> <strong>\u521b\u5efa\u96c6\u5408\uff1a<\/strong> db.createCollection( ) <\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p><strong>\u76f4\u63a5\u547d\u4ee4\u884c\uff1a<\/strong><\/p>\n<pre>&gt; use my_database\n&gt; db.createCollection(\"my_collection\")<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>mongo Shell\uff1a<\/strong><\/p>\n<pre>&gt; mongo\n&gt; use my_database\n&gt; db.createCollection(\"my_collection\")<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5176\u4ed6\u8bbe\u7f6e\u9009\u9879<\/strong><\/p>\n<p>\u9664\u4e86\u521b\u5efa\u6570\u636e\u5e93\u548c\u96c6\u5408\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b MongoDB \u547d\u4ee4\u8bbe\u7f6e\u5176\u4ed6\u9009\u9879\uff1a<\/p>\n<ul>\n<li> <strong>\u67e5\u770b\u6570\u636e\u5e93\u5217\u8868\uff1a<\/strong> show dbs<\/li>\n<li> <strong>\u67e5\u770b\u6536\u85cf\u5217\u8868\uff1a<\/strong> show collections<\/li>\n<li> <strong>\u5220\u9664\u6570\u636e\u5e93\uff1a<\/strong> db.dropDatabase()<\/li>\n<li> <strong>\u5220\u9664\u96c6\u5408\uff1a<\/strong> db. .drop() <\/li>\n<li> <strong>\u63d2\u5165\u6587\u6863\uff1a<\/strong> db. .insertOne( ) <\/li>\n<li> <strong>\u67e5\u8be2\u6587\u6863\uff1a<\/strong> db. .find( ) <\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u547d\u4ee4\u600e\u4e48\u8bbe\u7f6e\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u8bbe\u7f6emongodb\u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\uff08use\u548cdb.createcollection()\uff09\u6216mongo shell\uff08mongo\u3001use\u548cdb.createcollection()\uff09\u3002\u5176\u4ed6\u8bbe\u7f6e\u9009\u9879\u5305\u62ec\u67e5\u770b\u6570\u636e\u5e93\uff08show dbs\uff09\u3001\u67e5\u770b\u96c6\u5408\uff08show collections\uff09\u3001\u5220\u9664\u6570\u636e\u5e93\uff08db.dropdatabase()\uff09\u3001\u5220\u9664\u96c6\u5408\uff08db..drop()\uff09\u3001\u63d2\u5165\u6587\u6863\uff08db. \u5982\u4f55\u4f7f\u7528 MongoDB \u547d\u4ee4\u8bbe\u7f6e\u6570\u636e\u5e93 \u76f4\u63a5\u547d\u4ee4\u884c\u8bbe\u7f6e \u521b\u5efa\u6570\u636e\u5e93\uff1a use \u521b\u5efa\u96c6\u5408\uff08\u8868\uff09\uff1a db.createCollection( ) \u4f7f\u7528 mongo Shell \u8fde\u63a5 MongoDB\uff1a mongo \u5207\u6362\u6570\u636e\u5e93\uff1a use \u521b\u5efa\u96c6\u5408\uff1a db.createCollection( ) \u793a\u4f8b \u76f4\u63a5\u547d\u4ee4\u884c\uff1a &gt; use my_database &gt; db.createCollection(&#8220;my_collection&#8221;) \u767b\u5f55\u540e\u590d\u5236 mongo Shell\uff1a &gt; mongo &gt; use my_database &gt; db.createCollection(&#8220;my_collection&#8221;) \u767b\u5f55\u540e\u590d\u5236 \u5176\u4ed6\u8bbe\u7f6e\u9009\u9879 \u9664\u4e86\u521b\u5efa\u6570\u636e\u5e93\u548c\u96c6\u5408\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b MongoDB \u547d\u4ee4\u8bbe\u7f6e\u5176\u4ed6\u9009\u9879\uff1a \u67e5\u770b\u6570\u636e\u5e93\u5217\u8868\uff1a show dbs \u67e5\u770b\u6536\u85cf\u5217\u8868\uff1a show collections \u5220\u9664\u6570\u636e\u5e93\uff1a db.dropDatabase() \u5220\u9664\u96c6\u5408\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5367","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5367"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5367\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}