LoginSignup
5
6

More than 5 years have passed since last update.

mongo shellを使ってみる

Last updated at Posted at 2014-06-04

ターミナルとかからmongoDBをさわれる。

$ mongo

dbを選ぶ

.0とか.nsがあるディレクトリでmongo shellを起動。

> use <db name>
swiched to db <db name>
> db
<さっき設定したdbnameが出るはず。>

DBの設定を確認・変更

一部のmongod起動時のオプションは、ここからget, set可能。
例えばログに出力するクエリのレベルを設定したいときはこんな感じ。
http://docs.mongodb.org/manual/reference/method/db.setProfilingLevel/

> db.<collection name>.setProfilingLevel(1, 100)

クエリの実行内容を確認

explain()を使うと、find()したときどのように実行されたかを見られる。

> db.collection.find(<query>).explain()

このコマンドの結果返されるオブジェクト

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6