当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- All the way, I was forced to talk about C code debugging skills and remote debugging
- What is the meaning of sector sealing of filecoin mining machine since the main network of filecoin was put online
- 2020-08-15:什么情况下数据任务需要优化?
- 代码重构之法——方法重构分析
- An article will introduce you to HTML tables and their main attributes
- 解决 WPF 绑定集合后数据变动界面却不更新的问题
- 细数软件工程----各阶段必不可少的那些图
- 2020-08-24:什么是小文件?很多小文件会有什么问题?很多小文件怎么解决?(大数据)
- 行为型模式之解释器模式
- 2020-08-17:详细说下数据倾斜怎么解决?
猜你喜欢
Can you do it with only six characters?
GitHub: the foundation of the front end
Take you to learn the new methods in Es5
What is the tensor in tensorflow?
Isn't data product just a report? absolutely wrong! There are university questions in this category
2020-08-15:什么情况下数据任务需要优化?
打工人好物——磨炼钢铁意志就要这样高效的电脑
To teach you to easily understand the basic usage of Vue codemirror: mainly to achieve code editing, verification prompt, code formatting
An article will introduce you to HTML tables and their main attributes
ES6 learning notes (4): easy to understand the new grammar of ES6
随机推荐
JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:曾文旌
With this artifact, quickly say goodbye to spam messages
What is the meaning of sector sealing of filecoin mining machine since the main network of filecoin was put online
An article will introduce you to HTML tables and their main attributes
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
What is the purchasing supplier system? Solution of purchasing supplier management platform
Outsourcing is really difficult. As an outsourcer, I can't help sighing.
Elasticsearch Part 6: aggregate statistical query
IPFs rudder filecoin landing at the same time, fil currency price broke a thousand
谷歌浏览器实现视频播放加速功能
Novice guidance and event management system in game development
An article taught you to use HTML5 SVG tags
行为型模式之备忘录模式
Behind the record breaking Q2 revenue of Alibaba cloud, the cloud opening mode is reshaping
Visual rolling [contrast beauty]
Git rebase is in trouble. What to do? Waiting line
A small goal in 2019 to become a blog expert of CSDN
How much disk space does a new empty file take?
es创建新的索引库并拷贝旧的索引库 实践亲测有效!