MongoDB (3) MongoDB shell
1、连接数据库命令
连接本地数据库:
未设密码时:命令“mongo”即进入本地数据库 localhost:27017
连接远程数据库:
2、基本命令:
show dbs;查看所有数据库
use testdb;使用testdb数据库
show collections:查看所有集合(即表)
db.user.find();查看整表;
3、MongoDB CRUD Operations
CRUD operations create, read, update, and delete documents.
增加(Create)、读取查询(Retrieve)、更新(Update)和删除(Delete)
C reate new records
R etrieve existing records
Create Operations
创建
Create or insert operations add new documents to a collection. If the collection does not currently exist, insert operations will create the collection.
create或者insert动作是插入一条新数据到一个集合中,如果当前集合不存在,insert动作会创建一个新的集合。
MongoDB provides the following methods to insert documents into a collection:
MongoDB支持下面的方法向集合中插入数据
db.collection.insertOne()
New in version 3.2
db.collection.insertMany()
New in version 3.2
to be continue.....