2.3. SQL 和 MongoDB 对比

术语和概念

SQL 术语和概念 MongoDB 术语和概念
database database**(opens new window)**
table collection**(opens new window)**
row document (opens new window)BSON**(opens new window)**
column field**(opens new window)**
index index**(opens new window)**
table joins $lookup (opens new window)、嵌入式文档
primary key primary key**(opens new window)**
MongoDB 中自动设置主键为 _id (opens new window)字段
aggregation (e.g. group by) aggregation pipeline
参考 SQL to Aggregation Mapping Chart (opens new window).
SELECT INTO NEW_TABLE $out(opens new window)
参考 SQL to Aggregation Mapping Chart**(opens new window)**
MERGE INTO TABLE $merge (opens new window)(MongoDB 4.2 开始支持)
参考 SQL to Aggregation Mapping Chart (opens new window).
UNION ALL $unionWith (opens new window)(MongoDB 4.4 开始支持)
transactions transactions
下一节:MongoDB 的聚合框架以数据处理管道(Pipeline)的概念为模型。