当前位置:网站首页>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 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 .
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 .
边栏推荐
- 【目标检测】YOLOv5跑通VOC2007数据集
- PG basics -- Logical Structure Management (locking mechanism -- table lock)
- A need to review all the knowledge, H5 form is blocked by the keyboard, event agent, event delegation
- Summer safety is very important! Emergency safety education enters kindergarten
- Protection strategy of server area based on Firewall
- Promoted to P8 successfully in the first half of the year, and bought a villa!
- Niuke real problem programming - day20
- Niuke real problem programming - day13
- 【OBS】RTMPSockBuf_ Fill, remote host closed connection.
- CTFshow,信息搜集:web6
猜你喜欢
【深度学习】图像超分实验:SRCNN/FSRCNN
Bye, Dachang! I'm going to the factory today
Niuke real problem programming - Day17
【跟着江科大学Stm32】STM32F103C8T6_PWM控制直流电机_代码
众昂矿业:萤石继续引领新能源市场增长
Briefly describe the working principle of kept
【OBS】RTMPSockBuf_Fill, remote host closed connection.
2. 堆排序『较难理解的排序』
Niuke real problem programming - day16
Stm32cubemx, 68 sets of components, following 10 open source protocols
随机推荐
MySQL installation configuration 2021 in Windows Environment
Lidar Knowledge Drop
Niuke real problem programming - day14
Cocoscreator resource encryption and decryption
Ffmpeg --- image processing
CTFshow,信息搜集:web12
15、文本编辑工具VIM使用
Used by Jetson AgX Orin canfd
Ctfshow, information collection: web7
拜拜了,大厂!今天我就要去厂里
暑期安全很重要!应急安全教育走进幼儿园
Ctfshow, information collection: web4
Notes HCIA
什么是数据泄露
2. Heap sort "hard to understand sort"
Andriod --- JetPack :LiveData setValue 和 postValue 的区别
Ctfshow, information collection: web8
Unity之ASE实现卡通火焰
【目标检测】YOLOv5跑通VOC2007数据集
CTFshow,信息搜集:web2