Home Database Mysql Tutorial Mysql数据库存储引擎

Mysql数据库存储引擎

Jun 07, 2016 pm 05:38 PM
mysql storage engine database

简单介绍存储引擎就是指表的类型。数据库的存储引擎决定了表在计算机中的存储方式。存储引擎的概念是MySQl的特点,而且是一个插入式的存储引擎概念。这就决定了M

简单介绍

存储引擎就是指表的类型。数据库的存储引擎决定了表在计算机中的存储方式。存储引擎的概念是MySQl的特点,而且是一个插入式的存储引擎概念。这就决定了MySQl数据库中的表可以使用不同的存储方式存储。用户可以根据自己的不同要求,选择不同的存储方式、是否进行事务处理等。


查询方式及内容解析

使用SHOW ENGINES语句可以查看MySQL数据库支持的存储引擎类型。查询方法如下:

SHOW ENGINES;

SHOW ENGUNES语句可以使用“;”结束,也可以使用“\g”或者“\G”结束。“\g”与“;”的作用相同,“\G”可以让结果显示的更加美观。

mysql> SHOW ENGINES\G *************************** 1. row *************************** Engine: MRG_MYISAM Support: YES Comment: Collection of identical MyISAM tables Transactions: NO XA: NO Savepoints: NO *************************** 2. row *************************** Engine: InnoDB Support: DEFAULT Comment: Supports transactions, row-level locking, and foreign keys Transactions: YES XA: YES Savepoints: YES *************************** 3. row *************************** Engine: MyISAM Support: YES Comment: MyISAM storage engine Transactions: NO XA: NO Savepoints: NO ###############中间已省略################### *************************** 8. row *************************** Engine: MEMORY Support: YES Comment: Hash based, stored in memory, useful for temporary tables Transactions: NO XA: NO Savepoints: NO 8 rows in set (0.11 sec)

解析:查询结果中,Engine参数指存储引擎名称;Support参数说明MySQL是否支持该类引擎,YES表示支持;Comment参数指对该引擎的评论;Transactions 参数表示是否支持事务处理,YES表示支持;XA参数表示是否分布式交易处理XA规范,YES表示支持;Savepoints参数表示是否支持保存点,以便事务回滚到保存点,YES表示支持。

从查询结果中可以看出,MySQL支持的引擎参数包括MyISAM、MEMORY、InnoDB、ARCHIVE和MRG_MYISAM等。其中InnoDB为默认的存储引擎。可使用语句查询默认的存储引擎此代码如下:

SHOW VARIABLES LIKE 'storage_engine';

代码执行的结果如下:

mysql> SHOW VARIABLES LIKE 'storage_engine'; +----------------+--------+ | Variable_name | Value | +----------------+--------+ | storage_engine | InnoDB | +----------------+--------+ 1 row in set (0.10 sec)

解析:结果显示默认的存储引擎为InnoDB。如果想修改默认的存储引擎可以在配置文件my.ini中修改。将”default-storage-engine=InnoDB”更改为”default-storage-engine=MyISAM”。然后重启服务,修改生效。

使用SHOW TABLESTATUS可以查看某个库中所有表支持的存储引擎类型查询方法如下:

mysql> USE hellodb Database changed mysql> SHOW TABLE STATUS\G *************************** 7. row *************************** Name: toc Engine: MyISAM Version: 10 Row_format: Fixed Rows: 0 Avg_row_length: 0 Data_length: 0 Max_data_length: 2533274790395903 Index_length: 1024 Data_free: 0 Auto_increment: 1 Create_time: 2013-08-12 16:17:23 Update_time: 2013-08-12 16:17:23 Check_time: NULL Collation: utf8_general_ci Checksum: NULL Create_options: Comment:

  • 个人建议:

    存储日志或按时间增长的数据:MyISAM、ARCHIVE

    论坛应用:InnoDB

    电商订单:InnoDB

    数据量大:Infobright、NoSQL、Sphinx


    个人总结,,希望对博友们有用!!



    本文出自 “起点梦想” 博客,请务必保留此出处

  • Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

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

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    How to connect to the database of apache How to connect to the database of apache Apr 13, 2025 pm 01:03 PM

    Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.

    MySQL's Place: Databases and Programming MySQL's Place: Databases and Programming Apr 13, 2025 am 12:18 AM

    MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

    MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

    The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

    How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

    The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

    Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

    Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

    Solve database connection problem: a practical case of using minii/db library Solve database connection problem: a practical case of using minii/db library Apr 18, 2025 am 07:09 AM

    I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

    How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

    The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

    Centos install mysql Centos install mysql Apr 14, 2025 pm 08:09 PM

    Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

    See all articles