mongo 学习02- 基本指令

1.在mongo 中输入

  show dbs/show databases 显示当前所有数据库

  use 数据库名

               ---进入到指定的数据库中

  db

    --表示当前所取的数据库(类似this)

  show collections

    --显示数据库中所有的集合

2.数据库的CRUD的操作

  -向数据库中插入文档

  db.<collection>.insert(doc)

    --向集合中插入一个文档

    例子:向test数据库中,student集合中插入一个新的学生对象

      db.student.insert({name:'张宇',age:18,gender:'男'})

    一般数据库,与集合不需要手动创建,插入的时候创建就可以

  db.<collection>.find()

    --查询db数据库某集合的文档 

 

猜你喜欢

转载自www.cnblogs.com/liangfc/p/9758062.html