cfanbo / cfanbo.github.io

1 stars 0 forks source link

[教程]mongodb常用维护命令 | 学习笔记 #201

Open cfanbo opened 1 year ago

cfanbo commented 1 year ago

https://blog.haohtml.com/archives/12812/

1.客户端常用命令 #mongo >help //列出帮助 >db.help() //db级别的帮助 >db.mycollection.help() //collection 级别的帮助 常用命令: >show dbs //show database names >show collections //show collections in current database >use //set current database >db.foo.find() //list objects in collection foo >db.foo.find({a:1}) //list objects in foo where a == 1 >db.createCollection(name, { size : …, capped : …, max : … } ) //创建collection >db.dropDatabase() //删除库 >db.collection.count() //统计colleciton的数量 >db.collection.drop() //删除此colleciton >db.foo.find().count //某个数据的数量 >db.collection.find(…).limit(n) MongoDB与MySQL的对应关系如下表所示: MySQL