当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 2020 database technology conference helps technology upgrade
- What the hell is fastthreadlocal? The existence of ThreadLocal!!
- MongoDB与SQL常用语法对应表
- Call analysis of start method in JNI thread and callback analysis of run method
- Zero basis to build a web search engine of its own
- Elasticsearch database | elasticsearch-7.5.0 application construction
- Multi robot market share solution
- 细数软件工程----各阶段必不可少的那些图
- Kubernetes and OAM to build a unified, standardized application management platform knowledge! (Internet disk link attached)
- How does cglib implement multiple agents?
猜你喜欢

An article will take you to understand CSS alignment

上海巨微专用蓝牙广播芯片

Swagger 3.0 brushes the screen every day. Does it really smell good?

mongo 用户权限 登录指令

检测证书过期脚本

IPFs rudder filecoin landing at the same time, fil currency price broke a thousand

代码重构之法——方法重构分析

Will blockchain be the antidote to the global epidemic accelerating the transformation of Internet enterprises?

A small goal in 2019 to become a blog expert of CSDN

Zero basis to build a web search engine of its own
随机推荐
2020-09-03:裸写算法:回形矩阵遍历。
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:曾文旌
In depth to uncover the bottom layer of garbage collection, this time let you understand her thoroughly
Digital city responds to relevant national policies and vigorously develops the construction of digital twin platform
Using iceberg on kubernetes to create a new generation of cloud original data Lake
image operating system windows cannot be used on this platform
git远程库回退指定版本
An article takes you to understand CSS pagination examples
Use modelarts quickly, zero base white can also play AI!
Application of restful API based on MVC
Contract trading system development | construction of smart contract trading platform
Python 100 cases
Filecoin has completed a major upgrade and achieved four major project progress!
This project allows you to quickly learn about a programming language in a few minutes
Will blockchain be the antidote to the global epidemic accelerating the transformation of Internet enterprises?
An article taught you to download cool dog music using Python web crawler
How does cglib implement multiple agents?
[self taught unity2d legendary game development] map editor
2020-08-24:什么是小文件?很多小文件会有什么问题?很多小文件怎么解决?(大数据)
Use modelarts quickly, zero base white can also play AI!