通过sql之类的语法访问Mongodb [英] Mongodb access through sql like syntax

查看:66
本文介绍了通过sql之类的语法访问Mongodb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可以使用sql之类的语法访问mongodb的库.

示例

use db
select * from table1
insert into table1 values (a,b,c)
delete from table
select a,b,count(*) from table1 group by a,b
select a.field1,b.field2 from a,b where a.id=b.id

谢谢 拉曼

解决方案

仅当您仅执行极其简单的sql查询时,学习曲线才会很小.如果您的SQL查询范围是从X选择*",那么MongoDB似乎是一个绝妙的主意,可以切掉所有过于复杂的SQL.但是,如果您需要执行左外部连接,测试null,检查范围,子选择,分组和求和,那么在移到Mongo之后,您很快就会在办公桌上出现一个圆形凹痕.令人不快的妙语是,有一半时间,您要尝试执行的操作无法在Mongo界面中完成. Mongo代表着一个大胆的新世界,它取代数据库来执行诸如聚合和查询优化之类的工作,它仅存储数据,而所有的魔术都是通过缓慢地检索所有内容并将其存储在应用程序内存中,然后用代码执行所有这些操作来完成的. /p>

Is there any library where i can access mongodb by using sql like syntax.

Example

use db
select * from table1
insert into table1 values (a,b,c)
delete from table
select a,b,count(*) from table1 group by a,b
select a.field1,b.field2 from a,b where a.id=b.id

Thanks Raman

解决方案

The learning curve is small only if you are only doing extremely simple sql queries. If the extent of your SQL querying is "select * from X", then MongoDB looks like a brilliant idea to cut through all the too-complicated SQL. But if you need to perform left outer joins, test for null, check for ranges, subselects, grouping and summation, then you will soon end up with a round concave dent in your desk after being moved to Mongo. The sick punchline is that half the time, the thing you are trying to do can't be done in the Mongo interface. Mongo represents a bold new world where instead of databases doing things like aggregation and query optimization, it just stores data and all the magic is done by retrieving everything, slowly, storing it in app memory, and doing all that stuff in code instead.

这篇关于通过sql之类的语法访问Mongodb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆