当前位置:网站首页>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 .
One 、 Display database inventory 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 testDB
Both 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 .
Four 、 Delete databaseIf 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
5、 ... and 、 Copy databaseCopying 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 .
边栏推荐
- Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
- @Introduction and three usages of controlleradvice
- Connecting FTP server tutorial
- Do you know the relationship between the most important indicators of two strong wind control and the quality of the customer base
- Zhiting doesn't use home assistant to connect Xiaomi smart home to homekit
- 【数字IC验证快速入门】26、SystemVerilog项目实践之AHB-SRAMC(6)(APB协议基本要点)
- Stream learning notes
- Niuke real problem programming - day15
- CTFshow,信息搜集:web12
- [understanding of opportunity -40]: direction, rules, choice, effort, fairness, cognition, ability, action, read the five layers of perception of 3GPP 6G white paper
猜你喜欢
"Baidu Cup" CTF competition 2017 February, web:include
Do you know the relationship between the most important indicators of two strong wind control and the quality of the customer base
Ctfshow, information collection: web9
Change win10 Screensaver
Ctfshow, information collection: web10
什麼是數據泄露
Yyds dry goods inventory # solve the real problem of famous enterprises: cross line
Used by Jetson AgX Orin canfd
What is the process of ⼀ objects from loading into JVM to being cleared by GC?
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
随机推荐
Typescript release 4.8 beta
Niuke real problem programming - day15
CTFshow,信息搜集:web7
众昂矿业:萤石继续引领新能源市场增长
简述keepalived工作原理
Excerpted words
Protection strategy of server area based on Firewall
Ctfshow, information collection: web8
JSON parsing instance (QT including source code)
A need to review all the knowledge, H5 form is blocked by the keyboard, event agent, event delegation
Niuke real problem programming - Day17
Connecting FTP server tutorial
Ctfshow, information collection: web4
居然从408改考自命题!211华北电力大学(北京)
Stm32cubemx, 68 sets of components, following 10 open source protocols
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
Bye, Dachang! I'm going to the factory today
Niuke real problem programming - day14
Spatiotemporal deformable convolution for compressed video quality enhancement (STDF)
Ffmpeg --- image processing