MongoDB 创建数据库
MongoDB 教程
· 2019-03-05 20:14:42
语法
MongoDB 创建数据库的语法格式如下:
use DATABASE_NAME
如果数据库不存在,则创建数据库,否则切换到指定数据库。
实例
以下实例我们创建了数据库 codercto:
> use codercto switched to db codercto > db codercto >
如果你想查看所有数据库,可以使用 show dbs 命令:
> show dbs admin 0.000GB local 0.000GB >
可以看到,我们刚创建的数据库 codercto 并不在数据库的列表中, 要显示它,我们需要向 codercto 数据库插入一些数据。
> db.codercto.insert({"name":"码农教程"})
WriteResult({ "nInserted" : 1 })
> show dbs
local 0.078GB
codercto 0.078GB
test 0.078GB
>
MongoDB 中默认的数据库为 test,如果你没有创建新的数据库,集合将存放在 test 数据库中。
注意: 在 MongoDB 中,集合只有在内容插入后才会创建! 就是说,创建集合(数据表)后要再插入一个文档(记录),集合才会真正创建。
点击查看所有 MongoDB 教程 文章: https://codercto.com/courses/l/32.html
The Lean Startup
Eric Ries / Crown Business / 2011-9-13 / USD 26.00
更多中文介绍:http://huing.com Most startups fail. But many of those failures are preventable. The Lean Startup is a new approach being adopted across the globe, chan ging the way companies are built and ......一起来看看 《The Lean Startup》 这本书的介绍吧!
JS 压缩/解压工具
在线压缩/解压 JS 代码
Base64 编码/解码
Base64 编码/解码