六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 113|回复: 0

MongoDB基本操作

[复制链接]

升级  5.33%

14

主题

14

主题

14

主题

秀才

Rank: 2

积分
58
 楼主| 发表于 2013-1-12 13:26:22 | 显示全部楼层 |阅读模式
  SQL语法

db.AddUser(username,password)  添加用户db.auth(usrename,password)     设置数据库连接验证db.cloneDataBase(fromhost)     从目标服务器克隆一个数据库db.commandHelp(name)           returns the help for the commanddb.copyDatabase(fromdb,todb,fromhost)  复制数据库fromdb---源数据库名称,todb---目标数据库名称,fromhost---源数据库服务器地址db.createCollection(name,{size:3333,capped:333,max:88888})  创建一个数据集,相当于一个表db.currentOp()                 取消当前库的当前操作db.dropDataBase()              删除当前数据库db.eval(func,args)             run code server-sidedb.getCollection(cname)        取得一个数据集合,同用法:db['cname'] or db.getCollenctionNames()       取得所有数据集合的名称列表db.getLastError()              返回最后一个错误的提示消息db.getLastErrorObj()           返回最后一个错误的对象db.getMongo()                  取得当前服务器的连接对象get the server db.getMondo().setSlaveOk()     allow this connection to read from then nonmaster membr of a replica pairdb.getName()                   返回当操作数据库的名称db.getPrevError()              返回上一个错误对象db.getProfilingLevel()         db.getReplicationInfo()        获得重复的数据db.getSisterDB(name)           get the db at the same server as this onewdb.killOp()                    停止(杀死)在当前库的当前操作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=alldb.shutdownServer()            关闭当前服务程序db.version()                   返回当前程序的版本信息 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表