MongoDB基本操作
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() 返回当前程序的版本信息
页:
[1]