当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- C and C / C + + mixed programming series 5 - GC collaboration of memory management
- Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)
- es创建新的索引库并拷贝旧的索引库 实践亲测有效!
- Metersphere developer's Manual
- 打工人好物——磨炼钢铁意志就要这样高效的电脑
- Zero basis to build a web search engine of its own
- MRAM高速缓存的组成
- Swagger 3.0 brushes the screen every day. Does it really smell good?
- An article will take you to understand CSS3 fillet knowledge
- The method of realizing high SLO on large scale kubernetes cluster
猜你喜欢
The method of realizing high SLO on large scale kubernetes cluster
[byte jumps, autumn recruitment Posts open] ohayoo! Don't leave after school, I want to ask you to play games!!!
What is alicloud's experience of sweeping goods for 100 yuan?
Flink's datasource Trilogy 2: built in connector
Why is the LS command stuck when there are too many files?
ES中删除索引的mapping字段时应该考虑的点
How about small and medium-sized enterprises choose shared office?
Look! Internet, e-commerce offline big data analysis best practice! (Internet disk link attached)
Some operations kept in mind by the front end foundation GitHub warehouse management
Those who have worked in China for six years and a million annual salary want to share these four points with you
随机推荐
检测证书过期脚本
An article takes you to understand CSS pagination examples
递归、回溯算法常用数学基础公式
How much disk space does a file of 1 byte actually occupy
2020-08-17:详细说下数据倾斜怎么解决?
ES6 learning notes (2): teach you to play with class inheritance and class objects
Isn't data product just a report? absolutely wrong! There are university questions in this category
谷歌浏览器实现视频播放加速功能
Description of phpshe SMS plug-in
ES6 learning notes (3): teach you to use js object-oriented thinking to realize the function of adding, deleting, modifying and checking tab column
CloudQuery V1.2.0 版本发布
Why is quicksort so fast?
ado.net和asp.net的关系
In depth to uncover the bottom layer of garbage collection, this time let you understand her thoroughly
Pn8162 20W PD fast charging chip, PD fast charging charger scheme
Introduction to the development of small game cloud
意派Epub360丨你想要的H5模板都在这里,电子书、大转盘、红包雨、问卷调查……
上海巨微专用蓝牙广播芯片
EOS founder BM: what's the difference between UE, UBI and URI?
mongo 用户权限 登录指令