文章來自個人博客: https://www.lwxshow.com/db/mysql/mysql-mongodb-comparison-table.html html
查詢:
MySQL:
SELECT * FROM user
Mongo:
db.user.find()
MySQL:
SELECT * FROM user WHERE name = ’starlee’
Mongo:
db.user.find({‘name’ : ’starlee’})
插入:
MySQL:
INSERT INOT user (`name`, `age`) values (’starlee’,25)
Mongo:
db.user.insert({‘name’ : ’starlee’, ‘age’ : 25})
若是你想在MySQL裏添加一個字段,你必須:
ALTER TABLE user….
但在MongoDB裏你只須要:
db.user.insert({‘name’ : ’starlee’, ‘age’ : 25, ‘email’ : ’starlee@starlee.com’})
刪除:
MySQL:
DELETE * FROM user
Mongo:
db.user.remove({})
MySQL:
DELETE FROM user WHERE age < 30
Mongo:
db.user.remove({‘age’ : {$lt : 30}})
$gt : > ; $gte : >= ; $lt : < ; $lte : <= ; $ne : !=
更新: mysql