MongoDb 命令查询所有数据库列表
> show dbs
如果想查看当前连接在哪个数据库下面,可以直接输入db
> db
Admin
想切换到test数据库下面
> use test ====> 创建数据库|| 切换到已有的数据库
switched to db test
> db
Test
想查看test下有哪些表或者叫collection,可以输入
> show collections
system.indexes
user
想知道mongodb支持哪些命令,可以直接输入help
CODE:
> help
*************************
删除user表
> db.user.drop();
备份数据:
[falcon@www.fwphp.cn ~/mongodb/bin]$ ./mongodump -d test -o test999/
[falcon@www.fwphp.cn ~/mongodb/bin]$ ./mongodump --help
还原备份数据:
[falcon@www.fwphp.cn ~/mongodb/bin]$ ./mongorestore -d test -c user test999/test/test.bson
falcon@www.fwphp.cn ~/mongodb/bin]$ ./mongorestore --help
第二节:
db.createCollection("Account") 创建表===>
修改数据表名
db.Account.renameCollection("Account1")
查询聚集中字段的不同记录
> db.Account.distinct("UserName")
******************MongoDB数据删除*************************
db.[collectionName].remove({key:value})
删除集合sample中name等于c的纪录
db.sample.remove({name:"c"})