第七章 进阶指南
一数据库命令
命令的工作原理
#删除集合的操作
db.dropTest.drop()
#也可以使用如下操作,同上面的效果一样
#显示数据库中的所有集合
> show collections
blog
blog.posts
dropTest
foo
prices
Users
#删除集合
>db.runCommand({"drop":"dropTest"});
{ "ns" :"test.dropTest", "nIndexesWas" : 1, "ok" : 1 }
> show collections
blog
blog.posts
foo
prices
users
命令参考
#取得命令的最新参考
Command |
Attributes |
Help |
R S A |
Report status of a replica set from the POV of this server |
|
killOp |
R S A |
|
rolesInfo |
R |
Returns information about roles. |
saslContinue |
R S |
Subsequent steps in a SASL authentication conversation. |
dropIndexes |
W |
drop indexes for a collection 删除集合里name的索引 |
drop |
W |
drop a collection
|
cloneCollectionAsCapped |
W |
|
dbHash |
R S |
|
planCacheSetFilter |
R |
Sets index filter for a query shape. Overrides existing filter. |
_recvChunkStart |
R A |
internal |
writebacklisten |
R S A |
v3.0 disallowed internal command, present for compatibility only |
reIndex |
W S |
re-index a collection |
revokeRolesFromUser |
W |
Revokes roles from a user. |
parallelCollectionScan |
R S |
|
getnonce |
R S |
internal |
geoNear |
R S |
|
touch |
R S |
touch collection |
getMore |
R S |
retrieve more results from an existing cursor |
profile |
W S |
enable or disable performance profiling |
handshake |
R S |
internal |
compact |
R S |
compact collection |
group |
R |
http://dochub.mongodb.org/core/aggregation 分组 |
_recvChunkCommit |
R A |
internal |
splitChunk |
R A |
internal command usage only |
planCacheListPlans |
R |
Displays the cached plans for a query shape. |
dropDatabase |
W |
drop (delete) this database 删除数据库 |
replSetGetRBID |
R S A |
|
shardingState |
W A |
|
filemd5 |
R S |
example: |
authenticate |
R S |
internal |
killCursors |
R S |
kill a list of cursor ids |
connectionStatus |
R S |
Returns connection-specific information such as logged-in users and their roles 联接状态 |
mergeChunks |
R A |
Merge Chunks command |
logout |
R S |
de-authenticate |
driverOIDTest |
R S |
|
replSetSyncFrom |
R S A |
|
unsetSharding |
R S A |
internal |
R S |
Check if this server is primary for a replica pair/set; also if it is --master or --slave in simple master/slave setups.
|
|
_transferMods |
R A |
internal |
planCacheClearFilters |
R |
Clears index filter for a single query shape or, if the query shape is omitted, all filters for the collection. |
update |
R |
update documents 更新文档 |
ping |
R S |
a way to check that the server is alive. responds immediately even if server is in a db lock. 检查服务器联接是否正常 |
grantPrivilegesToRole |
W |
Grants privileges to a role |
createIndexes |
R |
|
connPoolStats |
R S |
stats about connections between servers in a replica set or sharded cluster. 联接池状态 |
invalidateUserCache |
R S A |
Invalidates the in-memory cache of user information |
R A |
list databases on this server 列出服务器上的所有数据库 |
|
dropAllRolesFromDatabase |
W |
Drops all roles from the given database. Before deleting the roles completely it must remove them from any users or other roles that reference them. If any errors occur in the middle of that process it's possible to be left in a state where the roles have been removed from some user/roles but otherwise still exist. |
shutdown |
R S A |
shutdown the database. must be ran against admin db and either (1) ran from localhost or (2) authenticated. If this is a primary in a replica set and there is no member within 10 seconds of its optime, it will not shutdown without force : true. You can also specify timeoutSecs : N to wait N seconds for other members to catch up. |
connPoolSync |
R S |
internal |
setShardVersion |
R S A |
internal |
fsync |
R S A |
|
getCmdLineOpts |
R S A |
get argv |
usersInfo |
R |
Returns information about users. |
_getUserCacheGeneration |