日期:2014-05-16  浏览次数:20429 次

mongodb常用查询和操作命令
db.system.users.find()
db.users.count()
db.users.ensureIndex({password:-1})
use test
db.users.getIndexes()
db.repairDatabase() 
show users
show dbs
db.users.find({username:{$in:['4d81a82398790']}}).explain()
db.users.dropIndexes() 
db.users.find().count()
db.users.find().limit(5)
db.users.find({"username":"ssa"})  
show collections 
db.users.remove()
db.user.remove({'username':'admin'})
db.user.insert({'username':'admin','age':21,'nickname':'admin'})
db.user.save({'username':'admin','age':21,'info':['12','12313','zzsd']})
db.createCollection("user")  
db.dropDatabase() 
show collections 
db.test.drop() 
db.copyDatabase('test','test1')
show profile
db.printCollectionStats()
db.addUser('admin','admin123')  
db.setProfilingLevel(2);
db.setProfilingLevel( 1 , 10 );
db.system.profile.find()