MongoDB与MySql常用命令对比
最近给朋友推荐哈mongodb
也很久没有去回顾这些数据库了,下面对mysql和mongodb常用命令做哈对比
123456789101112131415161718192021222324252627282930313233343536373839404142434445一、连接数据库
?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
?