mongoDB学习笔记六

第七章 进阶指南

 

一数据库命令

 

命令的工作原理

#删除集合的操作

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

replSetGetStatus

R S A

Report status of a replica set from the POV of this server
{ replSetGetStatus : 1 }
http://dochub.mongodb.org/core/replicasetcommands

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
{drop : <collectionName>}

删除当前数据库的所有数据

cloneCollectionAsCapped

W

{ cloneCollectionAsCapped:<fromName>, toCollection:<toName>, size:<sizeInBytes> }

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

http://dochub.mongodb.org/core/geo

touch

R S

touch collection
Page in all pages of memory containing every extent for the given collection
{ touch : <collection_name>, [data : true] , [index : true] }
at least one of data or index must be true; default is both are false

getMore

R S

retrieve more results from an existing cursor

profile

W S

enable or disable performance profiling
{ profile : <n> }
0=off 1=log slow ops 2=log all
-1 to get current values
http://docs.mongodb.org/manual/reference/command/profile/

handshake

R S

internal

compact

R S

compact collection
warning: this operation locks the database and is slow. you can cancel with killOp()
{ compact : <collection_name>, [force:<bool>], [validate:<bool>],
[paddingFactor:<num>], [paddingBytes:<num>] }
force - allows to run on a replica set primary
validate - check records are noncorrupt before adding to newly compacting extents. slower but safer (defaults to true in this version)

group

R

http://dochub.mongodb.org/core/aggregation

分组

_recvChunkCommit

R A

internal

splitChunk

R A

internal command usage only
example:
{ splitChunk:"db.foo" , keyPattern: {a:1} , min : {a:100} , max: {a:200} { splitKeys : [ {a:150} , ... ]}

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: { filemd5 : ObjectId(aaaaaaa) , root : "fs" }

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
usage: { mergeChunks : <ns>, bounds : [ <min key>, <max key> ], (opt) epoch : <epoch>, (opt) config : <configdb string>, (opt) shardName : <shard name> }

logout

R S

de-authenticate

driverOIDTest

R S

 

replSetSyncFrom

R S A

{ replSetSyncFrom : "host:port" }
Change who this member is syncing from.

unsetSharding

R S A

internal

isMaster

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.
{ isMaster : 1 }

是不是主服务器

_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

listDatabases

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

http://dochub.mongodb.org/core/fsynccommand

getCmdLineOpts

R S A

get argv

usersInfo

R

Returns information about users.

_getUserCacheGeneration

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值