データベース選択
use database
データベース一覧表示
show dbs
コレクション一覧表示
show collections
データベース削除
use database
db.dropDatabase()
データベースコピー
db.copyDatabase('fromDatabase', 'toDatabase')
コレクション作成
db.createCollection('collection')
コレクション削除
db.collection.drop()
コレクション名変更
db.oldCollection.renameCollection('newCollection')
コレクション複製
db.oldCollection.find().forEach(function (x) {db.newCollection.save(x)})
インデックス作成
OLD!!
db.collection.ensureIndex({name: 1})
New!!
db.collection.createIndex({name: 1})
インデックス削除
すべてのインデックス削除
db.collection.dropIndexes()
個別にインデックス削除
db.collection.dropIndex({name: 1})
全件表示
db.collection.find().forEach(printjson)
indexとかもろもろ確認
db.collection.stats()