MongoDBをちょっとだけ触ってみたよ

NoSQLデータベースファーストガイド

NoSQLデータベースファーストガイド

MongoDBをインストールしてちょっとだけ(本当にちょっとだけ)触ってみた。コマンドは本を読みつつ叩いただけ。
環境:Ubuntu 10.04 LTS Server 32bit

インストール

ソースからコンパイルしようと思ったけど面倒だったのでaptからインストール。

$ sudo apt-get install -y mongodb

使ってみる

$ mongo
> show dbs
admin
local
> help
HELP
        show dbs                     show database names
        show collections             show collections in current database
        show users                   show users in current database
        show profile                 show most recent system.profile entries with time >= 1ms
        use <db name>                set curent database to <db name>
        db.help()                    help on DB methods
        db.foo.help()                help on collection methods
        db.foo.find()                list objects in collection foo
        db.foo.find( { a : 1 } )     list objects in foo where a == 1
        it                           result of the last line evaluated; use to further iterate
> show users
> show profile
db.system.profile is empty
Use db.setProfilingLevel(2) will enable profiling
Use db.system.profile.find() to show raw profile entries
> db.users.save({ name : "sasaplus1" })
> show dbs
admin
local
test
> show collections
system.indexes
users
> db.users.find()
{ "_id" : ObjectId("4de64b50658babaabed11c45"), "name" : "sasaplus1" }
> bye

まだまださっぱりわかんない。


でもまあ、特に設定しなくてもいきなり値を書き込めるってのはわかった。これは確かにお手軽かも。
レプリケーションとかも機能的にできるみたいだし、いろいろ触って覚えたいなー。RDBまともに扱えないし。