您好,登錄后才能下訂單哦!
如果想查看當前連接在哪個數據庫下面,可以直接輸入db
> db
Admin
想切換到test數據庫下面
> use test
switched to db test
> db
Test想查看test下有哪些表或者叫collection,可以輸入
> show collections
system.indexes
user想知道mongodb支持哪些命令,可以直接輸入help
> 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.help();
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_r(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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。