mongodb的简单用法

来源:互联网 发布:已备案域名购买转入 编辑:程序博客网 时间:2024/06/05 14:20

use DATABASE_NAME 用于创建数据库。该命令如果数据库不存在,将创建一个新的数据库, 否则将返回现有的数据库。

show dbs查询数据库列表

use **db**使用某个数据库

db.dropDatabase() 命令用于删除现有的数据库

db.collection.drop() 用于从数据库中删除集合

> show dbs;iplocation  0.000GBlocal       0.000GBmyblog      0.000GB> use iplocationswitched to db iplocation> show collectionsusers>> db.users.find(){ "_id" : ObjectId("58fec001abc2d42aa8ded4ed"), "province" : "中国", "ip" : "1.0.1.1", "city" : "福州市" }{ "_id" : ObjectId("58fec001abc2d42aa8ded4ee"), "province" : "中国", "ip" : "1.0.1.0", "city" : "福州市" }{ "_id" : ObjectId("58fec01fabc2d42aa8ded4f0"), "province" : "中国", "ip" : "1.0.1.2", "city" : "福州市" }{ "_id" : ObjectId("58fec03eabc2d42aa8ded4f2"), "province" : "中国", "ip" : "1.0.1.3", "city" : "福州市" }



db.user.remove();
0 0
原创粉丝点击