Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of MySQL storage engine

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what is the use of MySQL storage engine for you. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

1. The main storage engine of MySQL:

. Innodb

. Myisam

. Memory

. Blackhole

Let's learn about them one by one.

Innodb is the default storage engine for MySQL5.5 and later to store data more securely. Before MySQL5.5, the default storage engine is faster than Innodb, but we pay more attention to the security of data. 'memory memory engine (all data is stored in memory) power off data and loss' blackhole will disappear immediately (like a black hole) no matter what is stored

View the sql statements for all storage engines:

Show engines; II. Examples to introduce them (similarities and differences between different storage engines when storing tables)

First of all, let's build a separate database.

Create database day45

Then switch to the database

Use day45

Create four tables for 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 the four tables, you will see the files of four different storage engines under the data file.

T3 tables do not have t3.MYD data files because the blackhole storage engine is like a black hole. If you throw a file into it, it will disappear, so it is difficult to store data in the file.

T4 table is a memory storage engine, which is stored in memory and temporarily stores data, but it is difficult to store data on hard disk, so there is no table data file.

Next, we insert a piece of data for the tables of each different storage engine to see what happens:

Insert into T1 values (1); insert into T2 values (1); insert into T3 values (1); insert into T3 values (1)

You can see that when querying the data of each table separately, T3 does not store data, because T3 is the blackhole storage engine, and the stored data will be lost immediately, so there will be no data in select. The experiment is not only going on so far, but when you restart MySQL and re-query the data of each table, you will find something new.

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

Because T4 refers to the memory storage engine and stores data in memory instead of permanently, data will be lost when MySQL is shut down and restarted

This is the end of this article on "what is the use of MySQL storage engine". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report