连接到数据库
[root@RHEL65 mongodb]# mongo
MongoDB shell version: 2.6.4
connecting to: test
>
查看数据库
> show dbs
admin (empty)
local 0.078GB
>
切换到数据库mydb
> use mydb
switched to db mydb
查看当前所在数据库
> db
mydb
创建2条记录,待插入
> j = { name : "mongo" }
{ "name" : "mongo" }
> k = { x : 3 }
{ "x" : 3 }
>
> db.testData.insert( j )
WriteResult({ "nInserted" : 1 })
> db.testData.insert( k )
WriteResult({ "nInserted" : 1 })
>
查看Collection
> show collections
system.indexes
testData
>
查询插入记录
> db.testData.find()
{ "_id" : ObjectId("53e76534ddaa3f82b14a8144"), "name" : "mongo" }
{ "_id" : ObjectId("53e7653bddaa3f82b14a8145"), "x" : 3 }
>
查看帮助
help
db.help()
db.mycoll.help()