日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java发送焦点做移键值_xiaoguozi's Blog

發(fā)布時間:2023/12/15 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java发送焦点做移键值_xiaoguozi's Blog 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

shell操作數(shù)據(jù)庫:

1.?超級用戶相關(guān):

1. #進(jìn)入數(shù)據(jù)庫admin

use admin

2. #增加或修改用戶密碼

db.addUser('name','pwd')

3. #查看用戶列表

db.system.users.find()

4. #用戶認(rèn)證

db.auth('name','pwd')

5. #刪除用戶

db.removeUser('name')

6. #查看所有用戶

show users

7. #查看所有數(shù)據(jù)庫

show dbs

8. #查看所有的collection

show collections

9. #查看各collection的狀態(tài)

db.printCollectionStats()

10. #查看主從復(fù)制狀態(tài)

db.printReplicationInfo()

11. #修復(fù)數(shù)據(jù)庫

db.repairDatabase()

12. #設(shè)置記錄profiling,0=off 1=slow 2=all

db.setProfilingLevel(1)

13. #查看profiling

show profile

14. #拷貝數(shù)據(jù)庫

db.copyDatabase('mail_addr','mail_addr_tmp')

15. #刪除collection

db.mail_addr.drop()

16. #刪除當(dāng)前的數(shù)據(jù)庫

db.dropDatabase()

2. 增刪改

1. #存儲嵌套的對象

db.foo.save({'name':'ysz','address':{'city':'beijing','post':100096},'phone':[138,139]})

2. #存儲數(shù)組對象

db.user_addr.save({'Uid':'yushunzhi@sohu.com','Al':['test-1@sohu.com','test-2@sohu.com']})

3. #根據(jù)query條件修改,如果不存在則插入,允許修改多條記錄

db.foo.update({'yy':5},{'$set':{'xx':2}},upsert=true,multi=true)

4. #刪除yy=5的記錄

db.foo.remove({'yy':5})

5. #刪除所有的記錄

db.foo.remove()

3. 索引

1. #增加索引:1(ascending),-1(descending)

2. db.foo.ensureIndex({firstname: 1, lastname: 1}, {unique: true});

3. #索引子對象

4. db.user_addr.ensureIndex({'Al.Em': 1})

5. #查看索引信息

6. db.foo.getIndexes()

7. db.foo.getIndexKeys()

8. #根據(jù)索引名刪除索引

9. db.user_addr.dropIndex('Al.Em_1')

4. 查詢

1. #查找所有

2. db.foo.find()

3. #查找一條記錄

4. db.foo.findOne()

5. #根據(jù)條件檢索10條記錄

6. db.foo.find({'msg':'Hello 1'}).limit(10)

7. #sort排序

8. db.deliver_status.find({'From':'ixigua@sina.com'}).sort({'Dt',-1})

9. db.deliver_status.find().sort({'Ct':-1}).limit(1)

10. #count操作

11. db.user_addr.count()

12. #distinct操作,查詢指定列,去重復(fù)

13. db.foo.distinct('msg')

14. #”>=”操作

15. db.foo.find({"timestamp": {"$gte" : 2}})

16. #子對象的查找

17. db.foo.find({'address.city':'beijing'})

5. 管理

1. #查看collection數(shù)據(jù)的大小

2. db.deliver_status.dataSize()

3. #查看colleciont狀態(tài)

4. db.deliver_status.stats()

5. #查詢所有索引的大小

6. db.deliver_status.totalIndexSize()

5.advanced queries:高級查詢

條件操作符$gt : >

$lt : <

$gte: >=

$lte: <=

$ne : !=、<>

$in : in

$nin: not in

$all: all

$not:反匹配(1.3.3及以上版本)

查詢name <> "bruce" and age >= 18的數(shù)據(jù)db.users.find({name: {$ne: "bruce"}, age: {$gte: 18}});查詢creation_date > '2010-01-01' and creation_date <= '2010-12-31'的數(shù)據(jù)db.users.find({creation_date:{$gt:new Date(2010,0,1), $lte:new Date(2010,11,31)});查詢age in (20,22,24,26)的數(shù)據(jù)db.users.find({age: {$in: [20,22,24,26]}});查詢age取模10等于0的數(shù)據(jù)db.users.find('this.age % 10 == 0');或者db.users.find({age : {$mod : [10, 0]}});匹配所有db.users.find({favorite_number : {$all : [6, 8]}});可以查詢出{name: 'David', age: 26, favorite_number: [ 6, 8, 9 ] }可以不查詢出{name: 'David', age: 26, favorite_number: [ 6, 7, 9 ] }查詢不匹配name=B*帶頭的記錄db.users.find({name: {$not: /^B.*/}});查詢age取模10不等于0的數(shù)據(jù)db.users.find({age : {$not: {$mod : [10, 0]}}});

#返回部分字段

選擇返回age和_id字段(_id字段總是會被返回)

db.users.find({}, {age:1});

db.users.find({}, {age:3});

db.users.find({}, {age:true});

db.users.find({ name : "bruce" }, {age:1});

0為false,非0為true

選擇返回age、address和_id字段db.users.find({ name : "bruce" }, {age:1, address:1});排除返回age、address和_id字段db.users.find({}, {age:0, address:false});

db.users.find({ name : "bruce" }, {age:0, address:false});數(shù)組元素個數(shù)判斷

對于{name: 'David', age: 26, favorite_number: [ 6, 7, 9 ] }記錄

匹配db.users.find({favorite_number: {$size: 3}});不匹配db.users.find({favorite_number: {$size: 2}});

$exists判斷字段是否存在

查詢所有存在name字段的記錄db.users.find({name: {$exists: true}});查詢所有不存在phone字段的記錄db.users.find({phone: {$exists: false}});

$type判斷字段類型

查詢所有name字段是字符類型的db.users.find({name: {$type: 2}});查詢所有age字段是整型的db.users.find({age: {$type: 16}});對于字符字段,可以使用正則表達(dá)式

查詢以字母b或者B帶頭的所有記錄db.users.find({name: /^b.*/i});

$elemMatch(1.3.1及以上版本)

為數(shù)組的字段中匹配其中某個元素

Javascript查詢和$where查詢

查詢age > 18的記錄,以下查詢都一樣db.users.find({age: {$gt: 18}});

db.users.find({$where: "this.age > 18"});

db.users.find("this.age > 18");

f = function() {return this.age > 18} db.users.find(f);排序sort()

以年齡升序asc

db.users.find().sort({age: 1});以年齡降序desc

db.users.find().sort({age: -1});限制返回記錄數(shù)量limit()

返回5條記錄

db.users.find().limit(5);

返回3條記錄并打印信息db.users.find().limit(3).forEach(function(user) {print('my age is ' + user.age)});結(jié)果my age is 18

my age is 19

my age is 20限制返回記錄的開始點skip()

從第3條記錄開始,返回5條記錄(limit 3, 5)

db.users.find().skip(3).limit(5);查詢記錄條數(shù)count()

db.users.find().count();

db.users.find({age:18}).count();

以下返回的不是5,而是user表中所有的記錄數(shù)量

db.users.find().skip(10).limit(5).count();

如果要返回限制之后的記錄數(shù)量,要使用count(true)或者count(非0)

db.users.find().skip(10).limit(5).count(true);

分組group()

假設(shè)test表只有以下一條數(shù)據(jù){ domain: "www.mongodb.org"

, invoked_at: {d:"2009-11-03", t:"17:14:05"}

, response_time: 0.05

, http_action: "GET /display/DOCS/Aggregation"

}使用group統(tǒng)計test表11月份的數(shù)據(jù)count:count(*)、total_time:sum(response_time)、avg_time:total_time/count;

db.test.group(

{ cond: {"invoked_at.d": {$gt: "2009-11", $lt: "2009-12"}}

, key: {http_action: true}

, initial: {count: 0, total_time:0}

, reduce: function(doc, out){ out.count++; out.total_time+=doc.response_time }

, finalize: function(out){ out.avg_time = out.total_time / out.count }

} );

[

{

"http_action" : "GET /display/DOCS/Aggregation",

"count" : 1,

"total_time" : 0.05,

"avg_time" : 0.05

}

總結(jié)

以上是生活随笔為你收集整理的java发送焦点做移键值_xiaoguozi's Blog的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。