Skip to content

11.1.6 MongoDB和关系型数据库术语对比图.md #80

Open
@lemontree8801

Description

@lemontree8801

写了一下MySQL与MongoDB的对比

概念对比

MySQL MongoDB
Database Database
Table Collection
Row JSON or BSON
Column Field
Index Index
table joins(表连接) $lookup或嵌套文档
primary key(主键) _id
统计分析 aggregation
Redo日志 Journal日志
Binlog日志 Oplog日志

模式语句对比

SQL模式语句 MongoDB模式语句
create table db.test.insert({x:1})或db.createCollection("test")
alter table add column db.test.update({},{'$set':{a:2}})
alter table drop column 删除字段$unset
create index db.test.createIndex({x:1,a:-1})
drop table或者truncate table db.test.drop()
drop database db.dropDatabase()
insert into db.test.insertOne()或db.test.insert()
select col1 from test order by a limit 1,2 db.test.find({xxx:10},{x:1,a:1}).sort({a:1}).skip(1).limit(2)
update db.test.update({x:1},{$set:{a:6}})
delete from db.test.deleteMany({x:1})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions