当前位置:网站首页>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 .
边栏推荐
- Message mechanism -- getting to know messages and message queues for the first time
- Notes de base sur les plans illusoires d'IA (triés en 10 000 mots)
- The primary market project galaxy will conduct public offering on coinlist on February 17
- Considerations for Apache deploying static web page projects
- Introduction and Principle notes of UE4 material
- Redis set password
- Blender多鏡頭(多機比特)切換
- Lunix reallocates root and home space memory
- ERROR 1118 (42000): Row size too large (> 8126)
- 【Unity3D】制作进度条——让Image同时具有Filled和Sliced的功能
猜你喜欢
sqoop创建job出现的一系列问题解决方法
Blender多鏡頭(多機比特)切換
Message mechanism -- getting to know messages and message queues for the first time
判断数组中是否存在重复元素
Pytest learning --base
MPLS experiment
allure--常用配置项
Shutter - canvas custom graph
Leetcode -- the nearest common ancestor of 236 binary tree
How to achieve the top progress bar effect in background management projects
随机推荐
Vscode set JSON file to format automatically after saving
2.14 is it Valentine's day or Valentine's day when the mainstream market continues to fluctuate and wait for changes?
Project practice, redis cluster technology learning (VII)
[200 Shengxin literatures] 95 multiomics exploration TNBC
【Unity3D】无法正确获取RectTransform的属性值导致计算出错
The nanny level tutorial of flutter environment configuration makes the doctor green to the end
01-spooldir
How to judge the quality of primary market projects when the market is depressed?
2021-09-12
stm32和電機開發(上比特系統)
使用Windbg静态分析dump文件(实战经验总结)
Notes de base sur les plans illusoires d'IA (triés en 10 000 mots)
《MySQL 8 DBA基础教程》简介
Webui automated learning
[jetbrain rider] an exception occurred in the construction project: the imported project "d:\visualstudio2017\ide\msbuild\15.0\bin\roslyn\microsoft.csh" was not found
[visual studio] every time you open a script of unity3d, a new vs2017 will be automatically reopened
2021-09-12
虚幻材质编辑器基础——如何连接一个最基本的材质
Aiphacode is not a substitute for programmers, but a tool for developers
pytest学习--base