美文网首页我爱编程
MongoDB基本语法(1)

MongoDB基本语法(1)

作者: wayne1125 | 来源:发表于2018-06-21 00:19 被阅读0次

一、创建数据库

启动mongo后输入

> use test     //切换到wayne数据库或创建wayne(创建时必须insert数据才能创建成功)
switched to db test
>db.test.insert({"name","test","age":25}))    //创建test成功
> db    //查看当前数据库
test
> db.test.insert({"name":"wayne"})
WriteResult({ "nInserted" : 1 })
> show dbs
local   0.078GB
runoob  0.078GB
test    0.078GB
> 

创建test数据库之后show dbs没有test数据库,必须insert数据后才会在show dbs 显示

二、删除数据库

>use test    //必须切换到某个指定数据库才能成功删除
switched to db test
> db.dropDatabase()
{ "dropped" : "test", "ok" : 1 }
> show dbs
local   0.078GB
runoob  0.078GB
> 

三、创建集合

> use test
switched to db test
> db.createCollection("testCollection")
{ "ok" : 1 }
> show collections
testCollection
system.indexes
>

相关文章

  • MongoDB基本语法(1)

    一、创建数据库 启动mongo后输入 创建test数据库之后show dbs没有test数据库,必须insert数...

  • MongoDB创建索引

    1、索引语法MongoDB使用 createIndex () 方法来创建索引, createIndex()方法基本...

  • mongodb基本语法

    参考链接 https://www.tutorialspoint.com/mongodb/index.htm 一.创...

  • MongoDB基本语法

  • MongoDB 基本语法

    Mongodb 此数据库的语法都是 db打头 mac安装mongodb参考地址:http://www.jiansh...

  • MongoDB基本语法

    在用Mongo库的时候,无法用generator生成底层,所以需要自己写实现。 查询的话就用mongoTempla...

  • Mongodb基本语法

    术语解析 |--------|:--------:|| database | 数据库 || collection ...

  • MongoDB基本语法

    1.查看所有数据库: 2.切换到数据库test: 3.创建集合(创建数据库): 4.插入文档/数据: test是...

  • MongoDB学习记录(二)

    MongoDB学习记录(二) MongoDB的查询 基本查询语句 基本的查询语句的语法:db.[集合名].fin...

  • MongoDB基本语法(2)

    show users //查看所有权限用户 一、删除集合 二、MongoDB 插入文档 MongoDB 使用...

网友评论

    本文标题:MongoDB基本语法(1)

    本文链接:https://www.haomeiwen.com/subject/dvpfyftx.html