抱歉,评论被关闭
MongoDB与MySql常用命令对比
天气热!空调也是破旧不堪,使人坐立不安,貌似磨练我的心境了。
最近给朋友推荐哈mongodb
也很久没有去回顾这些数据库了,下面对mysql和mongodb常用命令做哈对比
一、连接数据库
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
db.tb_table.update({"id":3},{$set:{"name":"lyca"}}) #mongodb
本文出自 “凹凸曼” 博客,请务必保留此出处 http://www.apoyl.com/?p=1030
目前盖楼

