当前位置:网站首页>Mongodb quickly get started with some simple operations of mongodb command line
Mongodb quickly get started with some simple operations of mongodb command line
2022-07-02 10:36:00 【Growth path of Xiaobo test】
stay MongoDB Inside , We usually use sets for the tables below the database collections To describe .
stay mongo Inside , Databases and tables can also be created without writing statements .
Common command usage is as follows :
1
Show all the databases
show dbs

2
Go to a database , Then perform some operations of creating tables
use Database name
If the database does not exist , Perform other operations later , For example, insert data into the table , The database will be created automatically

As can be seen from the above figure : It doesn't exist study Database , But use use study database , And after inserting a piece of data into a table , It will automatically create tables and databases .
db.createCollection(" Table name ")

3
Display all tables under a database
show tables / show collections: Display all tables under the database

4
Insert data into the table
db. Collection name .insert( Document object );
db.user.insert({"age":30,"name":" Xiaobo "});

You can see from the above picture that ,insert() The method is actually not recommended , It is recommended to use insertOne, insertMany, perhaps bulkWrite Method .
Usage reference :
db.user.insertOne({"age":30,"name":" Xiaobo 1"});
db.user.insertMany([{"age":30,"name":" Xiaobo 2"} ,{"age":30,"name":" Xiaobo 3 "}]); The effect is as follows :

bulkWrite The usage is complicated , I'll show you later .
5
Delete table
db. Collection name .drop()

6
Clear the data in the table
db. Collection name .remove({})

7
Inquire about
db. Collection name .find({})
Queries have many complex uses , I will introduce it in detail later
8
Delete database
use db name
db.dropDatabase() : Will delete the current database

That's all for this sharing , It is troublesome to add, delete, and modify the data in the query , Share later .
边栏推荐
- Solutions to a series of problems in sqoop job creation
- Pytest-- test report allure configuration
- Delivery mode design of Spartacus UI of SAP e-commerce cloud
- Flink calculates topn hot list in real time
- Pywin32打开指定窗口
- Sum the two numbers to find the target value
- pytest--之测试报告allure配置
- 快速做出原型
- Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
- [pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces
猜你喜欢

Pytest learning --base

【Unity3D】嵌套使用Layout Group制作拥有动态子物体高度的Scroll View

Considerations for Apache deploying static web page projects

pytest框架实现前后置

两数之和,求目标值

Database dictionary Navicat automatic generation version

Unreal material editor foundation - how to connect a basic material
![[unity3d] nested use layout group to make scroll view with dynamic sub object height](/img/b2/edab4ab48e1401934dcce7218df662.png)
[unity3d] nested use layout group to make scroll view with dynamic sub object height

Delivery mode design of Spartacus UI of SAP e-commerce cloud
![[pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces](/img/6f/e5a30dae824ccb22d1157818be58be.png)
[pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces
随机推荐
stm32和電機開發(上比特系統)
pytest框架实现前后置
01安装虚拟机
allure--常用配置项
MPLS experiment
[leetcode] sword finger offer 53 - I. find the number I in the sorted array
Blender海洋制作
[visual studio] every time you open a script of unity3d, a new vs2017 will be automatically reopened
Redis set password
两数之和,求目标值
The primary market project galaxy will conduct public offering on coinlist on February 17
Flink实时计算topN热榜
SQOOP 1.4.6 INSTALL
Applet development summary
Aiphacode is not a substitute for programmers, but a tool for developers
Vscode auto format
2021-09-12
Nonlinear optimization: establishment of slam model
"Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
Deep understanding of redis cache avalanche / cache breakdown / cache penetration