Collection
_id
BSON
cardinality
CRUD
driver
mongod
mongos
mongosh
namespace
ObjectId
primary key
query
SQL Terms/Concepts | MongoDB Terms/Concepts |
database | database |
table | collection |
row | document or BSON document |
column | field |
index | index |
table joins | $lookup, embedded documents |
primary key | primary key == _id 필드 |
SELECT INTO NEW_TABLE | $out |
MERGE INTO TABLE | $merge |
UNION ALL | $unionWith |
CREATE TABLE table_name | db.<collection_name>.insertOne() db.<collection_name>.insertMany() db.createCollection(”collection_name”) |
DROP TABLE table_name | db.<collection_name>.drop() |
CREATE INDEX ~ ON table_name(index, index) | db.<collection_name>.createIndex({}) |
INSERT INTO ~ VALUES ~ | db.<collection_name>.insertOne({}) |
SELECT * FROM table_name | db.<collection_name>.find() |
SELECT id, field2, field3 FROM table_name | db.<collection_name>.find({}, {field1: 1, field2: 1 }) |
SELECT user_id, status FROM peaple | db.collection.find({}, {user_id:1, status: 1, _id:0}) |
SELECT * FROM peaple WHERE status=”A” | db.peaple.find({ status:”A” }) |
SELECT user_id, status FROM peaple WHERE status = “A” |
db.peaple.find( { status: “A” }, {user_id: 1, status: 1, _id: 0 } ) |
SELECT COUNT(*) FROM peaple |
db.peaple.count() |
SELECT * FROM peaple WHERE status = “A” ORDER BY user_id DESC |
db.peaple.find( { status: “A” }).sort( {user_id: -1 } ) |
SELECT * FROM peaple LIMIT 1 |
db.peaple.findOne() or db.peale.find().limit(1) |
SELECT COUNT(*) FROM peaple WHERE age > 30 | db.peaple.count( { age: { $gt: 30 } } ) |
UPDATE peaple SET status = “C” WHERE age > 25 | db.peaple.updateMany( { age: { $gt: 25 } }, { $set: { status: “C” } } ) |
UPDATE peaple SET age = age + 3 WHERE status = “A” | db.peaple.updateMany( { status: “A” }, { $inc: { age: 3 } } ) |
DELETE FROM peaple WHERE status = “D” | db.peaple.deleteMany( { status: “D” } ) |
[프로그래머스] 중성화 여부 파악하기 (String, Date/Oracle(SQL)) (0) | 2021.03.03 |
---|---|
[프로그래머스] 이름에 el이 들어가는 동물 찾기 (String, Date/Oracle(SQL)) (0) | 2021.03.03 |
[프로그래머스] 루시와 엘라 찾기 (SQL String, Date / Oracle) (0) | 2021.02.16 |
[HackerRank] The Report (SQL/JOIN) (0) | 2021.02.06 |
[HackerRank] Average Population of Each Continent (SQL/JOIN) (0) | 2021.02.01 |