zoukankan      html  css  js  c++  java
  • MongoDB

    1 安装:https://blog.csdn.net/CC_leather/article/details/105051719#_6

    https://juejin.im/post/5e4cbcd66fb9a07c7c2d5a1c

    2 使用:

        show dbs # 显示所有数据的列表
        db # 显示当前数据库对象或集合
          use admin # 连接到一个指定admin的数据库。
    

    3 数据库名字

    不能是空字符串("")。
    不得含有' '(空格)、.、$、/、和 (空字符)。
    应全部小写。
    最多64字节。
    

    有一些数据库名是保留的,可以直接访问这些有特殊作用的数据库,admin/ local /config

    4 MongoDB shell 来连接 Mongodb 服务

    标准 URI 连接语法:
    mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
    

    创建数据库

    use test
    如果test 不存在则创建test,如果存在则切换到runoob

    show dbs
    没有test,要显示它,我们需要向 test 数据库插入一些数据。

    插入数据
    db.test.instert({name: 'xm'})

    删除数据库

    db.dropDatabase() // 当前数据库删除

    创建集合

    db.createCollection("hahaha")
    show tables 可以看到所以集合hahaha集合,表格// show collections 等于 show tables

    删除集合

    db.hahaha.drop() // hahaha集合删除

    插入文档

    insert() 或 save() 方法向集合中插入文档

    创建 查看 删除 更新
    use db1 创建数据库 show dbs db.createCollection("hahaha")
    db.db1.createCollection("table1") 创建集合 show tables / show collections db.table.drop() 删除集合
    db.table1.insert({name: 'xm'}) 插入文档 db.table1.find() 查看数据 db.table1.remove({name: 'xm'})删除 db.table.update({name: 'xm'}, {$set: {name: 'xm2'}}) 更新
  • 相关阅读:
    顺序表代码(指针实现)
    顺序表代码
    爬虫问题之Unknown command: crawl
    MongoDB的启动
    python复制文件到文件夹中
    .content和.text的区别
    ip协议,IP,子网掩码,ping命令是什么
    网络通信流程
    tcp和udp得区别
    flask中的目录解析
  • 原文地址:https://www.cnblogs.com/Running00/p/13098859.html
Copyright © 2011-2022 走看看