Let's learn about the MySQL storage engine

Let's learn about the MySQL storage engine

Preface

There are many file formats in daily life, and different file formats have corresponding storage methods and processing mechanisms (such as: .txt, .pdf, .mp4...)

There should be different processing mechanisms for storing different data.

Storage engines are different processing mechanisms

1. MySQL main storage engine:

. Innodb

. myisam

. memory

. blackhole

Let’s take a look at them one by one

'''
Innodb
It is the default storage engine for MySQL version 5.5 and later, which is more secure to store data.'''
'''
myisam
It is the default storage engine before MySQL 5.5. It is faster than Innodb, but we pay more attention to data security.
'''
memory
Memory engine (all data is stored in memory) power failure and data loss'''
'''
blackhole
Whatever is stored will disappear immediately (like a black hole)
'''

View the SQL statements for all storage engines:

show engines;

2. Examples of how different storage engines store tables

First, let's build a separate database

create database day45

Then switch to the database

use day45;

Create four tables with four different storage engines

create table t1(id int) engine=innodb;

create table t2(id int) engine=myisam;

create table t3(id int) engine=blackhole;

create table t4(id int) engine=memory;

After creating four tables, you will see four files with different storage engines under the data file.

The reason why the t3 table does not have the t3.MYD table data file is because the blackhole storage engine is like a black hole. If you throw a file into it, it will disappear, so it is not easy to store data in the file.

The t4 table is a memory storage engine. It is stored in memory and is a short-term storage of data. It is not easy to store it on the hard disk. Therefore, there is no table data file.

Next, we insert a piece of data into each table of different storage engines to see what the result will be:

insert into t1 values(1);

insert into t2 values(1);

insert into t3 values(1);

insert into t4 values(1);

You can see that when querying the data of each table separately, t3 does not store any data, because t3 is a blackhole storage engine, and the stored data will be lost immediately, so there will be no data when selecting. The experiment is not just for now. When you restart MySQL and re-query the data in each table, you will have new discoveries.

Obviously, the table of t4 also shows that there is no stored data at this time. Why is that?

Because t4 uses the memory storage engine, it stores data in memory instead of permanently. When you shut down MySQL and restart it, the data will be lost.

This is the end of this article about understanding MySQL storage engine. For more relevant MySQL storage engine content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • MySQL table type storage engine selection
  • MySQL data analysis storage engine example explanation
  • Comparison of storage engines supported by MySQL database
  • Differences and comparisons of storage engines in MySQL
  • Advantages and disadvantages of common MySQL storage engines

<<:  Tutorial on how to modify element.style inline styles

>>:  Two ways to implement HTML page click download file

Recommend

Implementation steps for installing java environment in docker

This article is based on Linux centos8 to install...

How to make your own native JavaScript router

Table of contents Preface Introduction JavaScript...

How to upload and download files between Linux server and Windows system

Background: Linux server file upload and download...

Teach you how to use Portainer to manage multiple Docker container environments

Table of contents Portainer manages multiple Dock...

Implementing license plate input function in WeChat applet

Table of contents Preface background Big guess Fi...

MySQL 8.0.12 winx64 detailed installation tutorial

This article shares the installation tutorial of ...

Four completely different experiences in Apple Watch interaction design revealed

Today is still a case of Watch app design. I love...

How to build Nginx image server with Docker

Preface In general development, images are upload...

Automatically install the Linux system based on cobbler

1. Install components yum install epel-rpm-macros...

Linux virtual memory settings tutorial and practice

What is Virtual Memory? First, I will directly qu...

Implementation of mysql configuration SSL certificate login

Table of contents Preface 1. MySQL enables SSL co...

Install CentOS system based on WindowsX Hyper-V

At present, most people who use Linux either use ...

Realize map aggregation and scattering effects based on vue+openlayer

Table of contents Preface: Result: 1. Polymerizat...