如何列出特定 MongoDB 資料庫中的所有集合?


如果你想列出特定資料庫中的所有集合,則需要首先切換資料庫。查詢如下 −

> use sample;
switched to db sample
> db.getCollectionNames();

輸出如下 −

[
   "copyThisCollectionToSampleDatabaseDemo",
   "deleteDocuments",
   "deleteDocumentsDemo",
   "deleteInformation",
   "employee",
   "internalArraySizeDemo",
   "sourceCollection",
   "updateInformation",
   "userInformation"
]

備用查詢可以如下 −

> show collections;

輸出如下 −

copyThisCollectionToSampleDatabaseDemo
deleteDocuments
deleteDocumentsDemo
deleteInformation
employee
internalArraySizeDemo
sourceCollection
updateInformation
userInformation

更新時間: 30-Jul-2019

192 次瀏覽

啟動你的 事業

透過完成該課程取得認證

開始實施
廣告
© . All rights reserved.