当前位置:网站首页>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 .
边栏推荐
- Spatial interpretation | comprehensive analysis of spatial structure of primary liver cancer
- Application of rxjs operator withlatestfrom in Spartacus UI of SAP e-commerce cloud
- Commutateur Multi - lentilles Blender
- lunix重新分配root 和 home 空间内存
- STM32 and motor development (upper system)
- 【leetcode】33. Search rotation sort array
- AutoCAD - layer Linetype
- Sum the two numbers to find the target value
- Vscode auto format
- 互联网快讯:腾讯会议应用市场正式上线;Soul赴港递交上市申请书
猜你喜欢
Flutter——Canvas自定义曲线图
MongoDB-快速上手MongoDB命令行的一些简单操作
"Talking about podcasts" vol.352 the age of children: breaking the inner scroll, what can we do before high school?
This article takes you to learn in detail what is fiber to home FTTH
01安装虚拟机
ue4材质的入门和原理笔记
Sum the two numbers to find the target value
Blender模型导入ue、碰撞设置
Flutter环境配置保姆级教程,让doctor一绿到底
VLAN experiment
随机推荐
SAP Spartacus express checkout design
Blender volume fog
使用Windbg静态分析dump文件(实战经验总结)
Mock Server基本使用方法
Unreal material editor foundation - how to connect a basic material
Lunix reallocates root and home space memory
高考的意义是什么
01 install virtual machine
两数之和,求目标值
Basic notes of illusory AI blueprint (10000 words)
Vscode auto format
Deep understanding of redis cache avalanche / cache breakdown / cache penetration
Allure -- common configuration items
网络通信学习
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
Blender海洋制作
VLAN experiment
Considerations for Apache deploying static web page projects
Blender stone carving
SQOOP 1.4.6 INSTALL