1、新增语句
| 方法 | 说明 | 语法 | 备注 |
| 新增 | MongoDB | db.getCollection('user').insert({"userId" : "014","uclass" : "B","name" : "Back","age" : 11,"email" : "b14@sina.com","birthday" : ISODate("2018-07-31T03:46:13.885Z"),"dataStatus" : 1}); |
|
| MySQL | INSERT INTO `sz-temp`.`user` (`userId`, `uclass`, `name`, `age`, `email`, `birthday`, `dataStatus`) VALUES ('014', 'B', 'Back13', '20', 'b14@sina.com', '2013-07-31 11:46:13', '0'); |
2、删除语句
| 方法 | 说明 | 语法 | 备注 |
| 删除 | MongoDB | db.getCollection('user').remove({"userId":"014"}); | |
| MySQL | delete from user where userId = '014'; |
3、修改语句
| 方法 | 说明 | 语法 | 备注 |
| 修改 | MongoDB | db.getCollection('user').update({"userId":"013"}, {$set:{"email":"b13@sina.com", "age":20}}); | |
| MySQL | update user set email = 'b13@sina.com', age = 20 where userId = '013'; |

本文对比了MongoDB和MySQL在新增、删除、修改和查询语句方面的基本用法,帮助读者理解两种数据库系统的异同。
最低0.47元/天 解锁文章
1507

被折叠的 条评论
为什么被折叠?



