MongoDB(三)增删改查
MongoDB作为非关系型数据库,还是传统数据库的增删改查有很大的区别的,这里只是将知识点进行了一下提纲挈领,实际用的时候,我们百度一下详细用法即可。先看大的几个方面: 一,对于里边的插入和删除不再过多赘述,相对来说知识点比较少。先来看一下更新,
MongoDB作为非关系型数据库,还是传统数据库的增删改查有很大的区别的,这里只是将知识点进行了一下提纲挈领,实际用的时候,我们百度一下详细用法即可。先看大的几个方面:
一,对于里边的插入和删除不再过多赘述,相对来说知识点比较少。先来看一下更新,常用操作还是非常有用的,需要我们根据实际情况灵活运用,这里只是提出了知识点,需要百度出例子来学习使用:
2,查询也是一样,看一下知识点的汇总,其实用几个,还是有规律的,比较容易记录的:
喎?http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD48cD48aW1nIHNyYz0="http://www.2cto.com/uploadfile/Collfiles/20141117/2014111709271863.png" alt="\" />
3,看一下固定集合Capped Collection:顾名思义是有着固定大小的集合,其优点是性能比较出色,以LRU(Least Recently Used最近最少使用)规则和插入顺序进行age-out(老化移出)处理。由于集合空间大小一定,当空间用完,新添加的对象将会取代集合中最旧的对象,永远保持最新的对象。
特点:对固定集合进行插入速度极快;按照插入顺序的查询输出速度极快;能够在插入最新数据时,淘汰最早数据。
用法:存储日志信息,最适合不过;缓存一些少量的文档……
创建:db.createCollection("my_collection",{capped:true,size:100000})
将普通集合转换为固定集合:db.runCommand({convertTocapped:"test",size:100000})
4,大文件集合(GridFS):
GridFS是一种在MongoDB中存储大二进制文件的机制,例如:存储巨大的文件,例如视频,高清图片等;GridFS会直接利用已经建立的复制或分片机制,故障恢复和扩展都很容易;可以避免用户上传内容的文件系统出现问题;其不会产生磁盘碎片。
GridFS使用两个表存储数据,默认fs.files:包含元数据对象,fs.chunks包含文件相关信息的二进制块。 通过利用bin目录下的mongofiles进行操作,其put(存储),get(取得)和list(列表)三个命令。非常简单的。
好了,简单说了一下MongoDB的增删改查,具体操作实例没有给出,用时查即可,需要我们知道这些东西,固定集合和大文件集合,是非常不错的想法,值得我们特别注意下。突然想起以前的看图心想系列,这里好像也可以是的,看着这些图,把其全部讲出来即可。这样就学的差不多了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

MongoDB and relational database: In-depth comparison This article will explore in-depth the differences between NoSQL database MongoDB and traditional relational databases (such as MySQL and SQLServer). Relational databases use table structures of rows and columns to organize data, while MongoDB uses flexible document-oriented models to better suit the needs of modern applications. Mainly differentiates data structures: Relational databases use predefined schema tables to store data, and relationships between tables are established through primary keys and foreign keys; MongoDB uses JSON-like BSON documents to store them in a collection, and each document structure can be independently changed to achieve pattern-free design. Architectural design: Relational databases need to pre-defined fixed schema; MongoDB supports

Detailed explanation of MongoDB efficient backup strategy under CentOS system This article will introduce in detail the various strategies for implementing MongoDB backup on CentOS system to ensure data security and business continuity. We will cover manual backups, timed backups, automated script backups, and backup methods in Docker container environments, and provide best practices for backup file management. Manual backup: Use the mongodump command to perform manual full backup, for example: mongodump-hlocalhost:27017-u username-p password-d database name-o/backup directory This command will export the data and metadata of the specified database to the specified backup directory.

Encrypting MongoDB database on a Debian system requires following the following steps: Step 1: Install MongoDB First, make sure your Debian system has MongoDB installed. If not, please refer to the official MongoDB document for installation: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/Step 2: Generate the encryption key file Create a file containing the encryption key and set the correct permissions: ddif=/dev/urandomof=/etc/mongodb-keyfilebs=512

Sorting index is a type of MongoDB index that allows sorting documents in a collection by specific fields. Creating a sort index allows you to quickly sort query results without additional sorting operations. Advantages include quick sorting, override queries, and on-demand sorting. The syntax is db.collection.createIndex({ field: <sort order> }), where <sort order> is 1 (ascending order) or -1 (descending order). You can also create multi-field sorting indexes that sort multiple fields.
