当前位置:网站首页>Introduction of mongod management database method
Introduction of mongod management database method
2022-07-07 15:19:00 【1024 questions】
Today, I mainly understand database management , Before operation MongoDB Service open .
If you want to view the database list, you can use show dbs.
By using MongoDB Built in handle in db To perform database operations . When operating on different databases , have access to db.getSiblings(database) Method or use <database>.
db=db.getSiblingDB('testDB')use testDBBoth of the above methods switch the current database handle to testDB, And put db Set the value of to the specified database .
3、 ... and 、 Create databaseMongoDB Not provided shell The command to create the database shown in . have access to <new_database_name> Create a new database handle , But unless you add the collection to a new database , Otherwise it will not actually be saved . In the following screenshot, create a new database handle and execute show dbs The original database is still displayed . After adding the collection, there will be a new database .

If there is a creation display, there will definitely be a deletion , Deleting a database is also very simple and practical dropDatabase() Method . above show dbs You can see that there are three databases , Use dropDatabase() Then let's see how many .
You can see that after deleting one, there are still 2 A database ,3-1=2 Well

Copying a database will create a database that is exactly the same except for its name , It is generally used for backup or archiving .
Create a copy of the database , You can switch to this database , And then use copyDatabase(origin,destination,[hostname]) To create a copy .origin The argument is a string , Specify the name of the database to be copied ,destination Parameters are specified here MongoDB The name of the database to be created on the server . Optional hostname Parameter assignment origin database MongoDB The hostname of the server ( If you copy databases from different hosts ). The screenshot below is to create a new newDB database , It adds a set and Person, Then create a by copying the database testDB database .show collections You can see that it also exists Person aggregate .

This is about MongoDB This is the end of the article on database management . I hope it will be helpful for your study , I also hope you can support the software development network .
边栏推荐
猜你喜欢

Summer safety is very important! Emergency safety education enters kindergarten

Ctfshow, information collection: web2

TypeScript 发布 4.8 beta 版本

暑期安全很重要!应急安全教育走进幼儿园

“百度杯”CTF比赛 2017 二月场,Web:include

简述keepalived工作原理

8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学

Ctfshow, information collection: web1

CTFshow,信息搜集:web3
![[data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering](/img/a4/7320f5d266308f6003cc27964e49f3.png)
[data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
随机推荐
Niuke real problem programming - Day12
摘抄的只言片语
Nacos一致性协议 CP/AP/JRaft/Distro协议
银行需要搭建智能客服模块的中台能力,驱动全场景智能客服务升级
众昂矿业:萤石继续引领新能源市场增长
上半年晋升 P8 成功,还买了别墅!
CTFshow,信息搜集:web3
Ctfshow, information collection: web12
Niuke real problem programming - Day17
How to release NFT in batches in opensea (rinkeby test network)
CTFshow,信息搜集:web7
广州开发区让地理标志产品助力乡村振兴
Ctfshow, information collection: web13
【Markdown语法高级】让你的博客更精彩(四:设置字体样式以及颜色对照表)
Ctfshow, information collection: web2
MySQL bit类型解析
Briefly describe the working principle of kept
【兰州大学】考研初试复试资料分享
【深度学习】图像超分实验:SRCNN/FSRCNN
With 8 modules and 40 thinking models, you can break the shackles of thinking and meet the thinking needs of different stages and scenes of your work. Collect it quickly and learn it slowly