mongodb的简单用法

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

show dbs查询数据库列表

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

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

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

> show dbs;
iplocation  0.000GB
local       0.000GB
myblog      0.000GB
> use iplocation
switched to db iplocation
> show collections
users
>
> 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();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值