学习/探索mongo
05 Jul 2020
|
|
ppt地址 ,资料都是整理
macos上安装和演示
#安装
brew tap mongodb/brew
brew install mongodb-community@4.4
#拉起
brew services start mongodb-community@4.4
#停止
brew services stop mongodb-community@4.4
# mongo shell
mongo 127.0.0.1:27017
mongo 和sql对应概念 区分
SQL术语/概念 | MongoDB 术语/概念 |
---|---|
database | database |
table | collection |
row | document 或 BSON document |
column | field |
index | index |
table joins (表联接) | $lookup, embedded documents (嵌入式文档) |
primary key 指定任何唯一的列或者列组合作为主键 | primary key 在 MongoDB 中, 主键自动设置为 _id 字段 |
aggregation (如:group by) | aggregation pipeline (聚合管道) 参考:SQL to Aggregation Mapping Chart |
SELECT INTO NEW_TABLE | $out 参考: SQL to Aggregation Mapping Chart |
MERGE INTO TABLE | $merge (从MongoDB 4.2开始可用) 参考:SQL to Aggregation Mapping Chart |
transactions | transactions |
二进制对应关系
MongoDB | MySQL | |
---|---|---|
数据库服务端 | mongod | mysqld |
数据库客户端 | mongo | mysql |
复制日志 | oplog | binlog |
恢复用日志 | journal | redolog |
最新 oplog 时间戳 | snapshot | 状态 |
---|---|---|
t0 | snapshot0 | committed |
t1 | snapshot1 | uncommitted |
t2 | snapshot2 | uncommitted |
t3 | snapshot3 | uncommitted |
ref
- https://www.runoob.com/mongodb/mongodb-osx-install.html
- https://aotu.io/notes/2020/06/07/sql-to-mongo-1/index.html