「基礎入門」MongoDBの基本的なコマンドのまとめ
1.show dbs
2.use pagedb
3.show collections
4.db.serverStatus()
{
“host" : “dev2",
“version" : “1.8.3",
“process" : “mongod",
“uptime" : 845446,
“uptimeEstimate" : 839192,
“localTime" : ISODate(“2011-12-27T04:03:12.512Z"),
“globalLock" : {
“totalTime" : 845445636925,
“lockTime" : 13630973982,
“ratio" : 0.016122827283818857,
“currentQueue" : {
“total" : 0,
“readers" : 0,
“writers" : 0
},
“activeClients" : {
“total" : 0,
“readers" : 0,
“writers" : 0
}
},
“mem" : {
“bits" : 64,
“resident" : 12208,
“virtual" : 466785,
“supported" : true,
“mapped" : 466139
},
“connections" : {
“current" : 27,
“available" : 792
},
“extra_info" : {
“note" : “fields vary by platform",
“heap_usage_bytes" : 70895216,
“page_faults" : 17213898
},
“indexCounters" : {
“btree" : {
“accesses" : 4466653,
“hits" : 4465526,
“misses" : 1127,
“resets" : 0,
“missRatio" : 0.00025231420484197006
}
},
“backgroundFlushing" : {
“flushes" : 14090,
“total_ms" : 15204393,
“average_ms" : 1079.0910574875797,
“last_ms" : 669,
“last_finished" : ISODate(“2011-12-27T04:02:28.713Z")
},
“cursors" : {
“totalOpen" : 3,
“clientCursors_size" : 3,
“timedOut" : 53
},
“network" : {
“bytesIn" : 63460818650,
“bytesOut" : 763926196104,
“numRequests" : 67055921
},
“opcounters" : {
“insert" : 7947057,
“query" : 35720451,
“update" : 16263239,
“delete" : 154,
“getmore" : 91707,
“command" : 68520
},
“asserts" : {
“regular" : 0,
“warning" : 1,
“msg" : 0,
“user" : 7063866,
“rollovers" : 0
},
“writeBacksQueued" : false,
“ok" : 1
}
5.指定されるデータベースを統計
use fragment
db.stats()
db.stats()
{
“db" : “fragment",
“collections" : 12,
“objects" : 384553,
“avgObjSize" : 3028.40198360174,
“dataSize" : 1164581068,
“storageSize" : 1328351744,
“numExtents" : 109,
“indexes" : 10,
“indexSize" : 16072704,
“fileSize" : 4226809856,
“ok" : 1
}
6.指定されたデータベース集合をクエリ
db.getCollectionNames()
db.getCollectionNames()
[
“17u",
“baseSe",
“bytravel",
“daodao",
“go2eu",
“lotour",
“lvping",
“mafengwo",
“sina",
“sohu",
“system.indexes"
]