最近给朋友推荐哈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 #mysql mongo.exe #mongodb #都是默认的端口 二、查询所有的数据库 show databases #mysql show 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
|