最近给朋友推荐哈mongodb
也很久没有去回顾这些数据库了,下面对mysql和mongodb常用命令做哈对比
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
一、连接数据库mysql -uroot -p123456 #mysqlmongo.exe #mongodb#都是默认的端口二、查询所有的数据库show databases #mysqlshow dbs #mongodb三、选择指定数据库use test #mysql、mongodb一样四、列出该数据库的所有表show tables #mysql、mongodb一样五、查询select * from tb_table where id=1 #mysql
db.tb_table.find({id:1}) #mongodb六、添加数据insert into tb_table(id,name) values(3,'lyc') #mysql
db.tb_table.save({"id":3,"name":"lyc"}) #mongodb
七、删除数据delete from tb_table where id=3 #mysql
db.tb_table.remove({"id":3}) #mongodb
八、更新数据update tb_table set name="lyca" where id=3 #mysql
|
本文对比了MySQL和MongoDB在数据库连接、查询、添加、删除、更新数据时的常用命令,帮助开发者理解两者之间的差异和应用场景。
1530

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



