当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- Some operations kept in mind by the front end foundation GitHub warehouse management
- Metersphere developer's Manual
- 意派Epub360丨你想要的H5模板都在这里,电子书、大转盘、红包雨、问卷调查……
- An article taught you to download cool dog music using Python web crawler
- How does cglib implement multiple agents?
- Elasticsearch database | elasticsearch-7.5.0 application construction
- 嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:王涛
- Event monitoring problem
- 统计项目代码行数
- Why is the LS command stuck when there are too many files?
猜你喜欢
上海巨微专用蓝牙广播芯片
实用工具类函数(持续更新)
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:曾文旌
How about small and medium-sized enterprises choose shared office?
How does cglib implement multiple agents?
How to play sortable JS vuedraggable to realize nested drag function of forms
2020-09-09:裸写算法:两个线程轮流打印数字1-100。
C# 调用SendMessage刷新任务栏图标(强制结束时图标未消失)
Introduction to Huawei cloud micro certification examination
Zero basis to build a web search engine of its own
随机推荐
Tron smart wallet PHP development kit [zero TRX collection]
Message queue - Analysis
【涂鸦物联网足迹】涂鸦云平台全景介绍
Using an example to understand the underlying processing mechanism of JS function
With this artifact, quickly say goodbye to spam messages
美团内部讲座|周烜:华东师范大学的数据库系统研究
Contract trading system development | construction of smart contract trading platform
2020 database technology conference helps technology upgrade
Ronglian completed US $125 million f round financing
Open source a set of minimalist front and rear end separation project scaffold
Top 5 Chinese cloud manufacturers in 2018: Alibaba cloud, Tencent cloud, AWS, telecom, Unicom
Zero basis to build a web search engine of its own
Can you do it with only six characters?
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
IPFs rudder filecoin landing at the same time, fil currency price broke a thousand
Elasticsearch Part 6: aggregate statistical query
Visual rolling [contrast beauty]
Novice guidance and event management system in game development
Use modelarts quickly, zero base white can also play AI!
How does cglib implement multiple agents?