D:\MongoDB\Server\3.4\bin>mongo
MongoDB shell version v3.4.16--g83c3022fe4
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.--g83c3022fe4
Server has startup warnings:
--04T11::41.286+ I CONTROL [initandlisten]
--04T11::41.286+ I CONTROL [initandlisten] ** WARNING: Access control is not enabled fo
r the database.
--04T11::41.286+ I CONTROL [initandlisten] ** Read and write access to data an
d configuration is unrestricted.
--04T11::41.286+ I CONTROL [initandlisten]
--04T11::41.286+ I CONTROL [initandlisten] Hotfix KB2731284 or later update is not inst
alled, will zero-out data files.
--04T11::41.286+ I CONTROL [initandlisten]
> show dbs
admin .000GB
local .000GB
test .000GB
> use students
switched to db students
> db.class.insert({'name':'吴唐华'})
WriteResult({ "nInserted" : })
> show collections
class
> db.class.drop()
true
> db.class2.insert({'name':'cwl','age':,'sex':})
WriteResult({ "nInserted" : })
> db.class2.insert({'name':'yt','age':,'sex':})
WriteResult({ "nInserted" : })
> db.class2.insert({'name':'jn','age':,'sex':})
WriteResult({ "nInserted" : })
> db.class2.find()
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : , "sex" : }
> db.class2.updata({'age':},{$set:{'age':}})
--04T14::23.195+ E QUERY [thread1] TypeError: db.class2.updata is not a function :
@(shell)::
> db.class2.update({'age':},{$set:{'age':}})
WriteResult({ "nMatched" : , "nUpserted" : , "nModified" : })
> db.class2.find()
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : , "sex" : }
> db.col.find({"name":{$type:}})
> db.class2.find({"name":{$type:}})
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : , "sex" : }
>
> db.class.find()pretty()
--04T15::22.253+ E QUERY [thread1] SyntaxError: missing ; before statement @(shell):
:
> db.class.pretty()
--04T15::30.826+ E QUERY [thread1] TypeError: db.class.pretty is not a function :
@(shell)::
> db.class2.update({'age':{$gt:},{$set:{'sex':}})
... db.class2.find({"name":{$type:}})
...
... db.class2.update({'age':},{$set:{'age':}}) > db.class2.update({'age':},{$set:{'age':}})
WriteResult({ "nMatched" : , "nUpserted" : , "nModified" : })
> db.class2.update({'age':},{$set:{'age':}})
WriteResult({ "nMatched" : , "nUpserted" : , "nModified" : })
> db.class2.update({'age':{$gt:}},{$set:{'sex':}},true,true)
WriteResult({ "nMatched" : , "nUpserted" : , "nModified" : })
> db.class2.find()
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : , "sex" : }
> db.class2.find().pretty()
{
"_id" : ObjectId("5d6f5ba19b7e3e911a123a83"),
"name" : "cwl",
"age" : ,
"sex" :
}
{
"_id" : ObjectId("5d6f5be99b7e3e911a123a84"),
"name" : "yt",
"age" : ,
"sex" :
}
{
"_id" : ObjectId("5d6f5c139b7e3e911a123a85"),
"name" : "jn",
"age" : ,
"sex" :
}
> db.class2.update({'name':'lys'},{$set:{'age':,"sex":'yes'}},true,true)
WriteResult({
"nMatched" : ,
"nUpserted" : ,
"nModified" : ,
"_id" : ObjectId("5d6f69b56685a146689b9147")
})
> db.class2.find()
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f69b56685a146689b9147"), "name" : "lys", "age" : , "sex" : "yes" }
> db.class2.update({'name':'lys'},{$set:{'age':,"sex":'yes'}},true,true)
WriteResult({ "nMatched" : , "nUpserted" : , "nModified" : })
> db.class2.find()
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f69b56685a146689b9147"), "name" : "lys", "age" : , "sex" : "yes" }
> db.class2.update({'name':'lys'},{$set:{'age':,"sex":'yes'}},true,true).find()
--04T15::22.078+ E QUERY [thread1] TypeError: db.class2.update(...).find is not a fun
ction :
@(shell)::
> db.class2.find(db.class2.update({'name':'lys'},{$set:{'age':,"sex":'yes'}},true,true))
Error: error: {
"ok" : ,
"errmsg" : "cannot compare to undefined",
"code" : ,
"codeName" : "BadValue"
}
> db.class2.find({'name':'lys'},{$set:{'age':,"sex":'yes'}},true,true).find()
--04T15::16.304+ E QUERY [thread1] TypeError: db.class2.find(...).find is not a funct
ion :
@(shell)::
> db.class2.find(db.class2.update({'name':'lys'},{$set:{'age':,"sex":'yes'}},true,true))
Error: error: {
"ok" : ,
"errmsg" : "cannot compare to undefined",
"code" : ,
"codeName" : "BadValue"
}
> db.class2.find({'name':'lys'},{$set:{'age':,"sex":'yes'}},true,true)
Error: error: {
"ok" : ,
"errmsg" : ">1 field in obj: { age: 12.0, sex: \"yes\" }",
"code" : ,
"codeName" : "BadValue"
}
> db.class2.find({'name':'mgq'},{$set:{'age':,"sex":'yes'}},true,true)
Error: error: {
"ok" : ,
"errmsg" : ">1 field in obj: { age: 12.0, sex: \"yes\" }",
"code" : ,
"codeName" : "BadValue"
}
> db.class2.find()
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : , "sex" : }
{ "_id" : ObjectId("5d6f69b56685a146689b9147"), "name" : "lys", "age" : , "sex" : "yes" }
> db.class2.find({'name':'lys'},{$set:{'age':,"sex":'yes'}},true,true)
Error: error: {
"ok" : ,
"errmsg" : ">1 field in obj: { age: 12.0, sex: \"yes\" }",
"code" : ,
"codeName" : "BadValue"
}
> db.class2.find({'by':'lys'})
> db.class2.find({'by':'lys'})
> db.class2.find({'by':'lys'}).pretty()
> db.class2.insert({'name':'yt','class':'','age':,'money':})
WriteResult({ "nInserted" : })
> db.class2.insert({'name':'clw','class':'','age':,'money':})
WriteResult({ "nInserted" : })
> db.class2.insert({'name':'szy','class':'','age':,'money':})
WriteResult({ "nInserted" : })
> db.class2.insert({'name':'szy','class':'','age':,'money':})
WriteResult({ "nInserted" : })
> db.class.find({$or:[{'class':''},{'class':''}]})
> db.class.find({$or:[{'class':''},{'class':''}]})
> db.class2.find({$or:[{'class':''},{'class':''}]})
{ "_id" : ObjectId("5d6f739e9b7e3e911a123a86"), "name" : "yt", "class" : "", "age" : , "money"
: }
{ "_id" : ObjectId("5d6f73bb9b7e3e911a123a87"), "name" : "clw", "class" : "", "age" : , "money
" : 20000 }
{ "_id" : ObjectId("5d6f73f69b7e3e911a123a88"), "name" : "szy", "class" : "", "age" : , "money
" : 20000000 }
{ "_id" : ObjectId("5d6f73ff9b7e3e911a123a89"), "name" : "szy", "class" : "", "age" : , "money
" : 20 }
> db.class2.insert({'name':'lm','class':'','age':,'money':})
WriteResult({ "nInserted" : })
> db.class.find({'money':{$gte:},$or:[{'class':},{'class':''}]}).pretty()
> db.class2.find({'money':{$gte:},$or:[{'class':},{'class':''}]}).pretty()
{
"_id" : ObjectId("5d6f739e9b7e3e911a123a86"),
"name" : "yt",
"class" : "",
"age" : ,
"money" :
}
{
"_id" : ObjectId("5d6f73bb9b7e3e911a123a87"),
"name" : "clw",
"class" : "",
"age" : ,
"money" :
}
> db.class2.find({'money':{$gte:},$or:[{'class':},{'class':''}]},{'_id':,'class':).pre
tty()
...
... db.class.find({'money':{$gte:},$or:[{'class':},{'class':''}]},{'class':}).pretty()
...
...
>
>
> db.class2.find({'money':{$gte:},$or:[{'class':},{'class':''}]},{'class':}).pretty()
{ "_id" : ObjectId("5d6f739e9b7e3e911a123a86"), "class" : "" }
{ "_id" : ObjectId("5d6f73bb9b7e3e911a123a87"), "class" : "" }
> db.class2.find({},{'mame':}).limit()
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83") }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84") }
> db.class2.find({},{'name':}).limit()
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl" }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt" }
> db.class2.find({},{'name':,'age':}).sort({'age':-})
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : }
{ "_id" : ObjectId("5d6f739e9b7e3e911a123a86"), "name" : "yt", "age" : }
{ "_id" : ObjectId("5d6f73bb9b7e3e911a123a87"), "name" : "clw", "age" : }
{ "_id" : ObjectId("5d6f73f69b7e3e911a123a88"), "name" : "szy", "age" : }
{ "_id" : ObjectId("5d6f73ff9b7e3e911a123a89"), "name" : "szy", "age" : }
{ "_id" : ObjectId("5d6f75509b7e3e911a123a8a"), "name" : "lm", "age" : }
{ "_id" : ObjectId("5d6f69b56685a146689b9147"), "name" : "lys", "age" : }
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : }
> db.class2.find({},{'name':,'age':}).sort({'age':})
{ "_id" : ObjectId("5d6f5ba19b7e3e911a123a83"), "name" : "cwl", "age" : }
{ "_id" : ObjectId("5d6f69b56685a146689b9147"), "name" : "lys", "age" : }
{ "_id" : ObjectId("5d6f73bb9b7e3e911a123a87"), "name" : "clw", "age" : }
{ "_id" : ObjectId("5d6f73f69b7e3e911a123a88"), "name" : "szy", "age" : }
{ "_id" : ObjectId("5d6f73ff9b7e3e911a123a89"), "name" : "szy", "age" : }
{ "_id" : ObjectId("5d6f75509b7e3e911a123a8a"), "name" : "lm", "age" : }
{ "_id" : ObjectId("5d6f5be99b7e3e911a123a84"), "name" : "yt", "age" : }
{ "_id" : ObjectId("5d6f5c139b7e3e911a123a85"), "name" : "jn", "age" : }
{ "_id" : ObjectId("5d6f739e9b7e3e911a123a86"), "name" : "yt", "age" : }
> db.class2.count() > db.class2.aggregate([{$group:{_id:'class',num:{$max:'money'}}}])
{ "_id" : "class", "num" : "money" }
> db.class2.aggregate([{$group:{_id:'class',num:{$max:'money'}}}])
{ "_id" : "class", "num" : "money" }
> db.class2.aggregate([{$group:{_id:'class',num:{$max:'money'}}}])
{ "_id" : "class", "num" : "money" }
> db.class2.aggregate([{$group:{'_id':'class',num:{$max:'money'}}}])
{ "_id" : "class", "num" : "money" }
> db.class2.aggregate([{$group:{_id:'class',num:{$max:'$money'}}}])
{ "_id" : "class", "num" : }

mongo数据库基本查询语句的更多相关文章

  1. Oracle数据库,查询语句、内置函数

    一.数据库的查询语句: 1.查询整个表: select * from 表名 例: 2.通过条件查询某一行数据: select * from 表名 where 字段名 例: 3.某一列数据去重查询: s ...

  2. WordPress 常用数据库SQL查询语句大全

    在使用WordPress的过程中,我们少不了要对数据库进行修改操作,比如,更换域名.修改附件目录.批量修改文章内容等等.这个时候,使用SQL查询语句可以大大简化我们的工作量. 关于如何操作SQL查询语 ...

  3. [数据库] SQL查询语句表行列转换及一行数据转换成两列

    原文来自:http://blog.csdn.net/Eastmount/article/details/50559008 本文主要讲述了SQL查询语句表之间的行列转换,同时也包括如何将一行数据转换成两 ...

  4. PHP-- 三种数据库随机查询语句写法

    1. Oracle,随机查询查询语句-20条 select * from (  select  *  from 表名 order by dbms_random.value ) where rownum ...

  5. 小觑数据库(SqlServer)查询语句执行过程

    近年来,越来越多的NoSql产品不断的以技术革命的者的身份跳出来:“你看哥是多么的快,你们关型型数据库真是战五渣阿”.是的,高性能的场景下NoSql真的很出彩.而我们关系型数据库只能在墙角哭泣&quo ...

  6. MYSQL 数据库高频查询语句整理

    一查询数值型数据: SELECT * FROM tb_name WHERE sum > 100; 查询谓词:>,=,<,<>,!=,!>,!<,=>,= ...

  7. 2019-2-14sql server数据库模糊查询语句

    sql server数据库模糊查询语句   确切匹配: select * from hs_user where ID=123 模糊查询 select * from hs_user where ID l ...

  8. MySQL数据库(查询语句)

    用户  角色  权限 select * from students1:查询这个表里的数据 select ssex from students1:在这个表里面查询ssex(性别) select dist ...

  9. 数据库基本查询语句(SQL常用增删改查语句 简单复习 mark)

    SQL常用增删改查语句 1增 1.1[插入单行]insert [into] <表名> (列名) values (列值)例:insert into Strdents (姓名,性别,出生日期) ...

随机推荐

  1. Codeforces - 1191E - Tokitsukaze and Duel - 博弈论 - 尺取

    https://codeforc.es/contest/1191/problem/E 参考自:http://www.mamicode.com/info-detail-2726030.html 和官方题 ...

  2. JS高级 — 函数的声明和表达式

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  3. 20180209-shutil模块

    下面讲解shutil模块的相关操作: 1.shutil.copyfileobj(fsrc, fdst, length=16*1024) 将fsrc文件内容拷贝到fdst文件中,length是指一次拷贝 ...

  4. 给定中序和后序遍历,求前序序列(C++递归方式实现)

    问题: 输入后序和中序,求中序遍历. 算法: void f2(string &pre,string in, string post) { ) //序列为空结束 return; ; //根节点 ...

  5. 不小心执行 rm -f,该如何恢复?

    每当我们在生产环境服务器上执行rm命令时,总是提心吊胆的,因为一不小心执行了误删,然后就要准备跑路了,毕竟人不是机器,更何况机器也有 bug,呵呵. 那么如果真的删除了不该删除的文件,比如数据库.日志 ...

  6. TCP和UDP的区别,以及它们对应的协议有哪些?

    TCP(传输控制协议) 是面向连接的协议.在收发数据前,一个TCP连接必须要经过“三次握手”建立可靠的连接.握手过程中传送的包里不包含数据,三次握手完毕后,客户端与服务器才正式开始传送数据.理想状态下 ...

  7. Codeforces 722E 组合数学 DP

    题意:有一个n * m的棋盘,你初始在点(1, 1),你需要去点(n, m).你初始有s分,在这个棋盘上有k个点,经过一次这个点分数就会变为s / 2(向上取整),问从起点到终点的分数的数学期望是多少 ...

  8. 没有dockerfile的情况下如何查看docker的镜像信息

    前言 参考资料 https://baijiahao.baidu.com/s?id=1564406878758073&wfr=spider&for=pc 很实用的功能哈.. 步骤 1.先 ...

  9. python运行windows终端程序

    其实是用python控制windows里的shell 1.windows有PowerShell,可以通过搜索打开,运行python不需要打开shell 2.用python里的subprocess函数, ...

  10. 【python实例】统计字符串里大写字母,小写字母的个数和非字母的个数

    """ 给定一个以下字符串:统计大写字母的个数,小写字母的个数,非字母的个数. str1 = "ajdkkKDKEK1343KFKiriromfkfKKRIOW ...