show dbs
show collections
use {database}
db.company.insert({"name":"A", age:27})
db.company.find()
db
db.{collection}.drop()
#创建数据库
先use {new_DB},然后insert data就可以了
# 删除DB
use cc
db.dropDatabase()
# find
db.boys.find()
db.boys.find({age: {$gt:30}}, {name:1, _id:0})
db.boys.find({name:/^jice/})
db.boys.find().limit(1)
db.boys.find().limit(10).skip(5);
db.boys.find({$or: [{age:88}, {age:28}]})
db.boys.findOne({name:"yue.zhang"})
# 关闭Mongodb server
use admin
db.shutdownServer();
#shard
db.runCommand({ listshards: 1 })
db.printShardingStatus( true)
use stat
db.pv.stats()
# 查看连接数
db.serverStatus().connections
# 创建集合
db.createCollection("{collection_name}")
# 创建复合索引
db.province_isp_index.ensureIndex({"uid":1, "province" : 1, "isp" : 1})
PS:
<!--[if !supportLists]-->1. <!--[endif]-->Shard模式下无法使用group命令
<!--[if !supportLists]-->2. <!--[endif]-->group命令要求group by key数量不超过10000个,否则会报错
<!--[if !supportLists]-->3. <!--[endif]-->无法同时group 和 count,官方建议将group结果拿到client端做count
参考:
#单机shard
http://www.mongodb.org/display/DOCS/A+Sample+Configuration+Session










