基本语法html
MongoDB 建立数据库的语法格式以下:mongodb
use DATABASE_NAME
若是数据库不存在,则建立数据库,不然切换到指定数据库。数据库
实例3d
如下实例咱们建立了数据库 coderschool:code
> use coderschool switched to db coderschool > db coderschool >
若是你想查看全部数据库,能够使用 show dbs 命令:htm
> show dbs local 0.078GB test 0.078GB >
能够看到,咱们刚建立的数据库 coderschool 并不在数据库的列表中, 要显示它,咱们须要向 coderschool 数据库插入一些数据。
实例:blog
> db.runoob.insert({"name":"技术拉近你我"}) WriteResult({ "nInserted" : 1 }) > show dbs coderschool 0.078GB local 0.078GB test 0.078GB >
操做过程图:教程
MongoDB 中默认的数据库为 test,若是你没有建立新的数据库,集合将存放在 test 数据库中。get
转载自Mongodb教程,原文地址:http://coderschool.cn/1725.htmlit