Liste von Datenbank Befehlen

See the [Commands] page for details on how to invoke a command.

Also: with the latest 1.5.x build, try running "mongod --rest" and then go to http://localhost:28017/_commands.

  • Requires Auth - requires authentication
  • Admin Only - if "Yes" this command is [privileged] - must be run against the admin database
  • Slave Okay - can be run on a replication slave db server
Command
Requires Auth
Admin Only
Slave Okay
Description
{assertinfo : 1} 
No
No
Yes
Info on any assertions thrown:
{dbasserted : boolean, 
asserted : boolean, 
assert : string, 
assertw : string, 
assertmsg : string, 
assertuser : string, 
ok : 1} 
{buildinfo : 1}
No
Yes Yes
Returns:
{version : dbVersion, gitVersion : gitCommitId, sysInfo : osInfo, ok : 1}
{ clone : from_host }
Yes
No
No
Copy the current database from another host to here.  DocPage
{collstats : collection_name}
No
No
No
Gets statistics about a collection.
{convertToCapped : collection_name, size : size_in_bytes}
No
No
No
Convert a collection to capped. This command is rarely used and is not currently supported with sharding.
{ copydb : 1, fromdb : ..., 
todb : ..., fromhost : ..., 
username: ..., nonce: ..., key: ... }


Yes
Yes
No
Copy a database, potentially from another host. The username, nonce, and key arguments are only required if the source database needs authentication.  DocPage
{ copydbgetnonce : 1, fromhost : ... }


Yes
Yes
No
Get a nonce for a subsequent call to copydb using a secure source database.  DocPage
{ count : collection_name, query : query_spec, fields : [field1, field2] }
No No No Returns a count for the specified query.
{ create : name, capped : boolean, size : N[, max : N] }
No No No Creates a collection
{dbstats:1}
No No Yes Display stats on the database. Invoke via db.stats() in the mongo shell.
{deleteIndexes : coll_name, 
index : index_name} 
No
No
?
Deletes one or all (if index_name is "*") indexes.
{distinct : collection_name, 
key : key_name 
[, query : a_query ] 
} 
No
No
Yes
Finds all distinct values for a given key.
{drop : collection_name} 
No
No
No
Drops a collection.
{dropDatabase : 1}
No
No
No
Drops this database.
{ok : 1}
{filemd5 : object_id, root : file_root}
No No Yes Finds the MD5 hash of a GridFS file. file_root is the prefix of the files and chunks collections. For example, with the default fs.files and fs.chunks collections, it would be "fs".
{findAndModify : collection_name, query: query_filter, update: update_modifier_object, sort: sort_order, remove: boolean, new: boolean}
No
No
No
Commanding for atomically updating and returning a document. See [findandmofify] for specifics.
{ok : 1}
{forceerror : 1}
No
No
Yes
Forces a database error.
{assertion : "forced error", errmsg : "db assertion failure", ok : 0}
{ fsync : 1[, async : true] }
No Yes Yes
{numFiles : N, ok : 1}
{getlasterror : 1}
No
No
Yes
Returns if there was an error on the previous database operation. [DocPage]
{err : error, n : numberOfErrors, ok : 1}
{getoptime : 1} 
No
No
Yes
{optime : Timestamp, ok : 1} 
{getpreverror : 1}
No
No
Yes
Returns when the last database error occured.
{err : error, n : numberOfErrors, nPrev : numberOfOperationsAgo, ok : 1}
{nIndexesWas : N, ok : 1}
No
No
No
{nIndexesWas : N, 
msg : "all indexes deleted for collection", 
ns : namespace, 
"ok" : 1} 
{ismaster : 1}
No No Yes Used with replica pairs .
{listDatabases : 1}
No Yes Yes Returns a list of database names and sizes.
{diagLogging : <n>} 
No
Yes
Yes
Generate a diagnostic log file for replay of operations.
{profile : integer} 
No
No
Yes
If passed -1, gets the profiling level, if passed 0-2, sets the profiling level.
{was : previousLevel, ok : 1} 
{queryTraceLevel : N}
No
Yes
Yes
{ok : 1}
{renameCollection : <collectionToRename>, to: <new collection name>, dropTarget: <boolean>}
No
Yes
No
Note that the full collection names must be provided (e.g., <dbname>.<collectionname>)
{repairDatabase : 1, 
preserveClonedFilesOnFailure : boolean, 
backupOriginalFiles : boolean} 
No No
Yes
Repairs/compacts this database.
{ok : 1} 
{reseterror : 1} 
No
No
Yes
Clears previous database errors.  Returns:
{ok : 1} 
{serverStatus : 1[, , repl : N ]} 
No
No
Yes
uptime/lock info/memory info - since 1.1.2
N:
  • 0 - none
  • 1 - local (doesn't have to connect to other server)
  • 2 - remote (has to check with the master)
{shutdown : 1}
Yes
Yes
Yes
Shuts down the database server.  Returns nothing.  DocPage
{logRotate : 1}
Yes
Yes
Yes
Rotate logs if using --logpath   DocPage

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

IF YOU HAVE A QUESTION, POST IT TO THE USER GROUP.

These pages are fine for comments, but for questions, your best bet will always be the MongoDB User Group.

blog comments powered by Disqus