inert into users value(3,5)

db.users.insert({a:3,b:5})

 

 

select a,b from users

db.users.find({}, {a:1,b:1})

select * from users

db.users.find()

select * from users where age=33

db.users.find({age:33})

select a,b from users where age=33

db.users.find({age:33}, {a:1,b:1})

select * from users where age=33 order by name

db.users.find({age:33}).sort({name:1})

select * from users where age>33

db.users.find({age:{$gt:33}})

select * from users where age!=33

db.users.find({age:{$ne:33}})

select * from users where name like "%Joe%"

db.users.find({name:/Joe/})

select * from users where name LIKE "Joe%"

db.users.find({name:/^Joe/})

select * from users where age>33 and age<=40

db.users.find({'age':{$gt:33,$lte:40}})

select * from users order by name desc

db.users.find().sort({name:-1})

select * from users where a=1 and b='q'

db.users.find({a:1,b:'q'})

select * from users limit 10 skip 20

db.users.find().limit(10).skip(20)

select * from users where a=1 or b=2

db.users.find( { $or : [ { a : 1 } , { b : 2 } ] } )

select * from users limit 1

db.users.findOne()

select order_id from orders o, order_line_items li where li.order_id=o.order_id and li.sku=12345

db.orders.find({"items.sku":12345},{_id:1})

select customer.name from customers,orders where orders.id="q179" and orders.custid=customer.id

var o = db.orders.findOne({_id:"q179"});

var name = db.customers.findOne({_id:o.custid})

 

 

select distinct last_name from users

db.users.distinct('last_name')

select count(*y)

from users

db.users.count()

select count(*y)

from users where age > 30

db.users.find({age: {'$gt': 30}}).count()

select count(age) from users

db.users.find({age: {'$exists': true}}).count()

 

 

create index myindexname on users(name)

db.users.ensureIndex({name:1})

create index myindexname ON users(name,ts desc)

db.users.ensureIndex({name:1,ts:-1})

 

 

explain select * from users where z=3

db.users.find({z:3}).explain()

 

 

update users set a=1 where b='q'

db.users.update({b:'q'}, {$set:{a:1}}, false, true)

update users set a=a+2 where b='q'

db.users.update({b:'q'}, {$inc:{a:2}}, false, true)

 

 

delete from users where z="abc"

db.users.remove({z:'abc'});

mongodb与SQL常见语句对照的更多相关文章

  1. MongoDB对应SQL语句

    -------------------MongoDB对应SQL语句------------------- 1.Create and Alter     1.     sql:         crea ...

  2. SQL中常见语句

    SQL中常见语句笔记: --替换字段中的回车符和换行符 ) ), '') --删除表命令 DROP TABLE [dbo].[MGoods_Test] --删除表中数据命令 DELETE FROM [ ...

  3. mongodb 跟踪SQL语句及慢查询收集

    有个需求:跟踪mongodb的SQL语句及慢查询收集 第一步:通过mongodb自带函数可以查看在一段时间内DML语句的运行次数. 在bin目录下面运行  ./mongostat -port 端口号  ...

  4. mongodb 操作语句与sql操作语句对比

    上行:SQL 操作语句 下行:Mongo 操作语句 CREATE TABLE USERS (a Number, b Number) db.createCollection("mycoll&q ...

  5. Mongodb 与 SQL 语句对照表

    In addition to the charts that follow, you might want to consider the Frequently Asked Questions sec ...

  6. [转]MySQL 最基本的SQL语法/语句

    MySQL 最基本的SQL语法/语句,使用mysql的朋友可以参考下.   DDL-数据定义语言(Create,Alter,Drop,DECLARE) DML-数据操纵语言(Select,Delete ...

  7. SQL常见笔试面试题

    sql理论题 1.触发器的作用? 答:触发器是一中特殊的存储过程,主要是通过事件来触发而被执行的.它可以强化约束,来维护数据的完整性和一致性,可以跟踪数据库内的操作从而不允许未经许可的更新和变化.可以 ...

  8. PL/SQL常见设置--Kevin的专栏

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  9. 最基本的SQL语法/语句

    DDL—数据定义语言(Create,Alter,Drop,DECLARE) DML—数据操纵语言(Select,Delete,Update,Insert) DCL—数据控制语言(GRANT,REVOK ...

随机推荐

  1. 对CCLE数据库可以做的分析--转载

    转载:http://www.bio-info-trainee.com/1327.html 收集了那么多的癌症细胞系的表达数据,拷贝数变异数据,突变数据,总不能放着让它发霉吧! 这些数据可以利用的地方非 ...

  2. Codeforces Round #319 (Div. 2) C. Vasya and Petya's Game 数学

    C. Vasya and Petya's Game time limit per test 1 second memory limit per test 256 megabytes input sta ...

  3. pairs 和 ipairs 的区别

    ipairs 在迭代过程中是会直接跳过所有手动设定key值的变量.pairs不会跳过手动设置key值的变量. 实例 tab = {,,a="cd","d"} f ...

  4. 【SQL Server高可用性】数据库复制:SQL Server 2008R2中数据库复制

    经常在论坛中看到有人问数据同步的技术,如果只是同步少量的表,那么可以考虑使用链接服务器+触发器,来实现数据同步,但当要同步的数据表比较多,那么可以考虑用数据库复制技术,来实现数据的同步. 一.使用场景 ...

  5. docker容器互联 (.net core容器,mysql容器)

    背景 有两个容器一个运行的.net core的项目 另一个运行的mysql的数据 并且这两个容器在同一个机子上(或者局域网),那么理论上.net core的项目去访问mysql是可以走内网的 但是容器 ...

  6. 【Demo】CSS3元素旋转、缩放、移动或倾斜

    CSS3元素旋转.缩放.移动或倾斜 代码: <!DOCTYPE html> <html lang="en"> <head> <meta c ...

  7. Linux 下升级JDK 1.7到1.8

    1.下载1.8的jdk rpm文件到linux系统 2.执行rpm -ivh jdk-8u151-linux-x64.rpm 选项详解: -a:查询所有套件: -b<完成阶段><套件 ...

  8. 在mysql中,如何改变列声明.

    C 在mysql中,如何改变列声明. 修改表 - 修改列名 使用 CHANGE COLUMN 来修改列的名字,还必须 设置 列的数据类型 mysql> desc test_tab -> / ...

  9. contentType 'text/xml; charset=UTF-8' conflicts问题

    Resin升级到3.1.3后,有同事发现原来在Resin 3.0.xx下成功运行的部分jsp文件(输出xml格式文件)编译出错: 1234567 500 Servlet Exception XXXXX ...

  10. Alone

    ---恢复内容开始--- 出处:皮皮bloghttp://blog.csdn.net/pipisorry/article/details/50709014 coding.net: 国内较好的代码托管平 ...