<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    狼愛上貍

    我胡漢三又回來了

    mongo的初體驗

    首先在mongo官網(wǎng)下載Windows的版本 

    啟動服務:mongod.exe --port 12345 --dbpath=c:\mongodb\db 
    顯示一下信息: 
    Fri Dec 04 14:30:32 Mongo DB : starting : pid = 0 port = 12345 dbpath = c:\mongo 
    db\db master = 0 slave = 0  32-bit 

    ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data 

    **       see http://blog.mongodb.org/post/137788967/32-bit-limitations for more 

    Fri Dec 04 14:30:32 db version v1.1.4-, pdfile version 4.5 
    Fri Dec 04 14:30:32 git version: c67c2f7dd681152f1784c8e1c2119b979e65881d 
    Fri Dec 04 14:30:32 sys info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LI 
    B_VERSION=1_35 
    Fri Dec 04 14:30:32 waiting for connections on port 12345 


    啟動客戶端:mongo.exe localhost:12345 

    檢查是否正常:db.foo.save({a:1,b:9}) 
         db.foo.find({a:1}) 
    控制臺顯示:{ "_id" : ObjectId("4b18b5b56f40000000006cec"), "a" : 1, "b" : 9 } 


    添加數(shù)據(jù):db.foo.save({a:1,b:9}) 

    查詢數(shù)據(jù):db.foo.find({a:1})  //{a:1}是查詢條件,當為空時查詢所有 
      db.foo.findOne({a:1}) //顯示出一條數(shù)據(jù) 

    刪除數(shù)據(jù):db.foo.remove({a:1}) //刪除a=1的數(shù)據(jù) 

    表的數(shù)據(jù)量:db.foo.find().count() 

    顯示數(shù)據(jù)指定的條數(shù):db.foo.find().limit(n) 

    顯示庫名:db.foo.getDB() 

    獲取索引值:db.foo.getIndexes() 

    表的統(tǒng)計:db.foo.stats() 

    刪除表:db.foo.drop() 

    獲取不重復的列:db.foo.distinct( key ) - eg. db.foo.distinct( 'x' ) 

    忽略前面的幾行:db.other.find({a:2}).skip(2)//忽略a=2中的前面2行 

    方法幫助:db.foo.help() 


    HELP 
            show dbs                     show database names 
            show collections             show collections in current database 
            show users                   show users in current database 
            show profile                 show most recent system.profile entries with time >= 1ms 
            use <db name>                set curent database to <db name> 
            db.help()                    help on DB methods 
            db.foo.help()                help on collection methods 
            db.foo.find()                list objects in collection foo 
            db.foo.find( { a : 1 } )     list objects in foo where a == 1 
            it                           result of the last line evaluated; use to further iterate 


    DB methods: 
            db.addUser(username, password) 
            db.auth(username, password) 
            db.cloneDatabase(fromhost) 
            db.commandHelp(name) returns the help for the command 
            db.copyDatabase(fromdb, todb, fromhost) 
            db.createCollection(name, { size : ..., capped : ..., max : ... } ) 
            db.currentOp() displays the current operation in the db 
            db.dropDatabase() 
            db.eval(func, args) run code server-side 
            db.getCollection(cname) same as db['cname'] or db.cname 
            db.getCollectionNames() 
            db.getLastError() - just returns the err msg string 
            db.getLastErrorObj() - return full status object 
            db.getMongo() get the server connection object 
            db.getMongo().setSlaveOk() allow this connection to read from the nonmaster member of a replica pair 
            db.getName() 
            db.getPrevError() 
            db.getProfilingLevel() 
            db.getReplicationInfo() 
            db.getSisterDB(name) get the db at the same server as this onew 
            db.killOp() kills the current operation in the db 
            db.printCollectionStats() 
            db.printReplicationInfo() 
            db.printSlaveReplicationInfo() 
            db.printShardingStatus() 
            db.removeUser(username) 
            db.repairDatabase() 
            db.resetError() 
            db.runCommand(cmdObj) run a database command.  if cmdObj is a string, turns it into { cmdObj : 1 } 
            db.setProfilingLevel(level) 0=off 1=slow 2=all 
            db.shutdownServer() 
            db.version() current version of the server 

    DBCollection help 
            db.foo.count() 
            db.foo.dataSize() 
            db.foo.distinct( key ) - eg. db.foo.distinct( 'x' ) 
            db.foo.drop() drop the collection 
            db.foo.dropIndex(name) 
            db.foo.dropIndexes() 
            db.foo.ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups 
            db.foo.find( [query] , [fields]) - first parameter is an optional queryfilter. second parameter is optional set of fields to return.  e.g. db.foo.find( { x : 77 } , { name : 1 , x : 1 } ) 
            db.foo.find(...).count() 
            db.foo.find(...).limit(n) 
            db.foo.find(...).skip(n) 
            db.foo.find(...).sort(...) 
            db.foo.findOne([query]) 
            db.foo.getDB() get DB object associated with collection 
            db.foo.getIndexes() 
            db.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } ) 
            db.foo.mapReduce( mapFunction , reduceFunction , <optional params> ) 
            db.foo.remove(query) 
            db.foo.renameCollection( newName ) renames the collection 
            db.foo.save(obj) 
            db.foo.stats() 
            db.foo.storageSize() - includes free space allocated to this collection 
            db.foo.totalIndexSize() - size in bytes of all the indexes 
            db.foo.totalSize() - storage allocated for all data and indexes 
            db.foo.update(query, object[, upsert_bool]) 
            db.foo.validate() - SLOW 
            db.foo.getShardVersion() - only for use with shardin
    來自: http://canofy.javaeye.com/blog/540926

    posted on 2011-03-23 10:22 狼愛上貍 閱讀(437) 評論(0)  編輯  收藏 所屬分類: Mongo

    主站蜘蛛池模板: 无码精品人妻一区二区三区免费看| 国产一级淫片视频免费看| 偷自拍亚洲视频在线观看99| 亚洲日韩图片专区第1页| 日韩亚洲国产二区| 成人毛片免费播放| 亚洲高清免费在线观看| 久久久久国色AV免费观看| 特级无码毛片免费视频| 亚洲免费福利在线视频| 亚洲欧洲日韩综合| 亚洲毛片在线观看| 亚洲女同成av人片在线观看| 亚洲福利精品电影在线观看| 日韩中文字幕在线免费观看 | 亚洲精品制服丝袜四区| 亚洲Av无码国产情品久久| 免费黄色毛片视频| 国产成人免费爽爽爽视频| 亚洲视频免费观看| 久久久久久久久久国产精品免费| 一级毛片免费在线观看网站| 麻豆69堂免费视频| 黄色一级毛片免费看| 色五月五月丁香亚洲综合网| 亚洲精品国产第一综合99久久| 亚洲av日韩av无码av| 亚洲AV无码久久久久网站蜜桃| 亚洲精品免费在线视频| 91大神亚洲影视在线| 亚洲一区二区三区首页| 亚洲伊人久久大香线蕉苏妲己| 久久亚洲精品AB无码播放| 国产精品亚洲аv无码播放| 亚洲va久久久噜噜噜久久| 国产亚洲人成网站观看| 久久久久久a亚洲欧洲aⅴ| 亚洲av无码一区二区三区网站| 亚洲成a人片77777老司机| 久久久无码精品亚洲日韩京东传媒 | 亚洲妇熟XXXX妇色黄|