当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Zero basis to build a web search engine of its own
- Markdown tricks
- EOS founder BM: what's the difference between UE, UBI and URI?
- Analysis of serilog source code -- how to use it
- Axios learning notes (2): easy to understand the use of XHR and how to package simple Axios
- What is the meaning of sector sealing of filecoin mining machine since the main network of filecoin was put online
- [self taught unity2d legendary game development] map editor
- Bitcoin once exceeded 14000 US dollars and is about to face the test of the US election
- A concise tutorial for Nacos, ribbon and feign
- 意派Epub360丨你想要的H5模板都在这里,电子书、大转盘、红包雨、问卷调查……
猜你喜欢
C# 调用SendMessage刷新任务栏图标(强制结束时图标未消失)
[elastic search engine]
What grammar is it? ]
Those who have worked in China for six years and a million annual salary want to share these four points with you
An article taught you to use HTML5 SVG tags
How to make characters move
Message queue - Analysis
Understanding formatting principles
Unity performance optimization
2020-08-18:介绍下MR过程?
随机推荐
Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)
An article taught you to download cool dog music using Python web crawler
Introduction to the development of small game cloud
Try to build my mall from scratch (2): use JWT to protect our information security and perfect swagger configuration
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王涛
The legality of IPFs / filecoin: protecting personal privacy from disclosure
Helping financial technology innovation and development, atfx is at the forefront of the industry
Hdu3974 assign the task segment tree DFS order
统计项目代码行数
打工人好物——磨炼钢铁意志就要这样高效的电脑
An article takes you to understand CSS gradient knowledge
C and C / C + + mixed programming series 5 - GC collaboration of memory management
This project allows you to quickly learn about a programming language in a few minutes
【涂鸦物联网足迹】涂鸦云平台全景介绍
行为型模式之解释器模式
How much disk space does a file of 1 byte actually occupy
Diamond standard
To teach you to easily understand the basic usage of Vue codemirror: mainly to achieve code editing, verification prompt, code formatting
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
Event monitoring problem