当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- ado.net和asp.net的关系
- Stickinengine architecture 11 message queue
- 2020年第四届中国 BIM (数字建造)经理高峰论坛即将在杭举办
- Call analysis of start method in JNI thread and callback analysis of run method
- Isn't data product just a report? absolutely wrong! There are university questions in this category
- Try to build my mall from scratch (2): use JWT to protect our information security and perfect swagger configuration
- JVM memory allocation - xms128m - xmx512m - XX: permsize = 128M - XX: maxpermsize = 512M
- ES中删除索引的mapping字段时应该考虑的点
- [elastic search engine]
- Flink's datasource Trilogy: direct API
猜你喜欢
What kind of music do you need to make for a complete game?
A small goal in 2019 to become a blog expert of CSDN
An article will introduce you to CSS3 background knowledge
2020-08-15:什么情况下数据任务需要优化?
Code generator plug-in and creator preform file analysis
2020-08-29:进程线程的区别,除了包含关系之外的一些区别,底层详细信息?
Summary of front-end performance optimization that every front-end engineer should understand:
CCR coin frying robot: the boss of bitcoin digital currency, what you have to know
An article will take you to understand CSS3 fillet knowledge
An article will take you to understand SVG gradient knowledge
随机推荐
Using iceberg on kubernetes to create a new generation of cloud original data Lake
上海巨微专用蓝牙广播芯片
Why is the LS command stuck when there are too many files?
Pn8162 20W PD fast charging chip, PD fast charging charger scheme
Use modelarts quickly, zero base white can also play AI!
2020-08-18:介绍下MR过程?
CloudQuery V1.2.0 版本发布
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王涛
Multi robot market share solution
How to make characters move
Python 100 cases
Unity performance optimization
大数据处理黑科技:揭秘PB级数仓GaussDB(DWS) 并行计算技术
大会倒计时|2020 PostgreSQL亚洲大会-中文分论坛议程安排
Understanding formatting principles
细数软件工程----各阶段必不可少的那些图
事务的本质和死锁的原理
美团内部讲座|周烜:华东师范大学的数据库系统研究
Python basic variable type -- list analysis
Use modelarts quickly, zero base white can also play AI!