mongodb基本使用
MongoDB 基本 使用
2023-09-27 14:21:15 时间
库操作:
glc-test:PRIMARY> db.help() DB methods: db.adminCommand(nameOrDocument) - switches to 'admin' db, and runs command [just calls db.runCommand(...)] db.aggregate([pipeline], {options}) - performs a collectionless aggregation on this database; returns a cursor db.auth(username, password) db.cloneDatabase(fromhost) - deprecated db.commandHelp(name) returns the help for the command db.copyDatabase(fromdb, todb, fromhost) - deprecated db.createCollection(name, {size: ..., capped: ..., max: ...}) db.createView(name, viewOn, [{$operator: {...}}, ...], {viewOptions}) db.createUser(userDocument) db.currentOp() displays currently executing operations in the db db.dropDatabase() db.eval() - deprecated db.fsyncLock() flush data to disk and lock server for backups db.fsyncUnlock() unlocks server following a db.fsyncLock() db.getCollection(cname) same as db['cname'] or db.cname db.getCollectionInfos([filter]) - returns a list that contains the names and options of the db's collections db.getCollectionNames() db.getLastError() - just returns the err msg string db.getLastErrorObj() - return full status object db.getLogComponents() db.getMongo() get the server connection object db.getMongo().setSlaveOk() allow queries on a replication slave server db.getName() db.getPrevError() db.getProfilingLevel() - deprecated db.getProfilingStatus() - returns if profiling is on and slow threshold db.getReplicationInfo() db.getSiblingDB(name) get the db at the same server as this one db.getWriteConcern() - returns the write concern used for any operations on this db, inherited from server object if set db.hostInfo() get details about the server's host db.isMaster() check replica primary status db.killOp(opid) kills the current operation in the db db.listCommands() lists all the db commands db.loadServerScripts() loads all the scripts in db.system.js db.logout() db.printCollectionStats() db.printReplicationInfo() db.printShardingStatus() db.printSlaveReplicationInfo() db.dropUser(username) db.repairDatabase() db.resetError() db.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into {cmdObj: 1} db.serverStatus() db.setLogLevel(level,<component>) db.setProfilingLevel(level,slowms) 0=off 1=slow 2=all db.setWriteConcern(<write concern doc>) - sets the write concern for writes to the db db.unsetWriteConcern(<write concern doc>) - unsets the write concern for writes to the db db.setVerboseShell(flag) display extra information in shell output db.shutdownServer() db.stats() db.version() current version of the server # 获取该实例上所有的数据库: glc-test:PRIMARY> show dbs admin 0.000GB apple 0.000GB config 0.000GB google 0.000GB local 0.008GB test 0.000GB # 获取当前连接的数据库: glc-test:PRIMARY> db admin glc-test:PRIMARY> db.getName() admin # 切换到指定数据库: glc-test:PRIMARY> use apple switched to db apple glc-test:PRIMARY> db.getName() apple # 删除当前所在数据库: ##
相关文章
- MongoDB 安装
- mode 连接 MongoDB 插入内容
- centos7 下设置 mongodb 开机启动 (重点)
- koa 基础(二十一)nodejs 操作mongodb数据库 --- 查询数据
- 微服务技术系列教程(46)-SpringBoot整合MongoDB(文章评论案例)
- Linux下后台方式启动mongodb
- Docker 安装 MongoDB
- mongodb基本语句
- Flink MongoDB CDC 在 XTransfer 的生产实践|Flink CDC 专题
- MongoDB:如何正常关闭服务(转)
- java使用mongoDB和freemarker注意事项
- MongoDB之Java測试代码(DAO层)
- MongoDB(2.2)MongoDB的安装与基本使用
- mongoDB 3.0 安全权限访问控制 -摘自网络
- MongoDB基本管理命令
- MongoDB基本命令操作