当前位置:网站首页>Common syntax corresponding table of mongodb and SQL
Common syntax corresponding table of mongodb and SQL
2020-11-06 21:24:00 【Irving the procedural ape】
For writing often SQL Classmate , Write at the beginning mongoDB I'm not used to it , The following table sorts out the common SQL grammar , Function and corresponding MongoDB Correspondence grammar , For reference only .
Terms and concepts
SQL |
MongoDB |
database | database |
table | collection |
row | document |
column | field |
index | index |
table joins | $lookup |
primary key | primary key |
SELECT INTO NEW_TABLE | $out |
MERGE INTO TABLE | $merge(mongodb > 4.2) |
UNION ALL | $unionWith (mongodb > 4.4) |
transactions | transactions |
Grammar correspondence table
SQL | MongoDB |
CREATE TABLE people ( id MEDIUMINT NOT NULL AUTO_INCREMENT, user_id Varchar(30), age Number, status char(1), PRIMARY KEY (id) ) |
db.createCollection("people")
db.people.insertOne( { user_id: "abc123", age: 55, status: "A" } ) |
ALTER TABLE people ADD join_date DATETIME |
db.people.updateMany( { }, { $set: { join_date: new Date() } } ) |
ALTER TABLE people DROP COLUMN join_date |
db.people.updateMany( { }, { $unset: { "join_date": "" } } ) |
CREATE INDEX idx_user_id_asc ON people(user_id) |
db.people.createIndex( { user_id: 1 } ) |
CREATE INDEX idx_user_id_asc_age_desc ON people(user_id, age DESC) |
db.people.createIndex( { user_id: 1, age: -1 } ) |
DROP TABLE people | db.people.drop() |
INSERT INTO people(user_id, age,status) VALUES ("bcd001",45,"A") |
db.people.insertOne( { user_id: "bcd001", age: 45, status: "A" } ) |
SELECT * FROM people | db.people.find() |
SELECT id, user_id, status FROM people |
db.people.find( { }, &n......... |
版权声明
本文为[Irving the procedural ape]所创,转载请带上原文链接,感谢
边栏推荐
- To Lianyun analysis: why is IPFs / filecoin mining so difficult?
- 2020-08-24:什么是小文件?很多小文件会有什么问题?很多小文件怎么解决?(大数据)
- Road to simple HTML + JS to achieve the most simple game Tetris
- JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
- What are the highlights of Huawei mate 40 series with HMS?
- Summary of front-end performance optimization that every front-end engineer should understand:
- Why is quicksort so fast?
- 实用工具类函数(持续更新)
- html+ vue.js Implementing paging compatible IE
- Zero basis to build a web search engine of its own
猜你喜欢
Tron smart wallet PHP development kit [zero TRX collection]
C# 调用SendMessage刷新任务栏图标(强制结束时图标未消失)
Description of phpshe SMS plug-in
Summary of front-end performance optimization that every front-end engineer should understand:
【涂鸦物联网足迹】物联网基础介绍篇
An article will introduce you to HTML tables and their main attributes
Flink's datasource Trilogy: direct API
Diamond standard
EOS founder BM: what's the difference between UE, UBI and URI?
Novice guidance and event management system in game development
随机推荐
Elasticsearch database | elasticsearch-7.5.0 application construction
Diamond standard
An article will take you to understand CSS alignment
How to make characters move
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
jenkins安装部署过程简记
检测证书过期脚本
[self taught unity2d legendary game development] map editor
Application insights application insights use application maps to build request link views
An article will take you to understand SVG gradient knowledge
Hdu3974 assign the task segment tree DFS order
2020-08-29:进程线程的区别,除了包含关系之外的一些区别,底层详细信息?
How does cglib implement multiple agents?
【涂鸦物联网足迹】物联网基础介绍篇
2020-09-04:函数调用约定了解么?
This project allows you to quickly learn about a programming language in a few minutes
C and C / C + + mixed programming series 5 - GC collaboration of memory management
Python 100 cases
【学习】接口测试用例编写和测试关注点
DC-1 target