MySQL Sql_mode's no_engine_substitution

Source: Internet
Author: User

Knowledge Reserve:

1, MySQL has a large number of storage engines, but only a default storage engine, usually it is InnoDB

2, MySQL can be sql_mode to control the behavior of MySQL database, today we want to talk about is no_engine_substitution

3, no_engine_subtitution function: MySQL can specify the engine clause when CREATE TABLE, this engine clause is used to specify the storage engine of the table, then the problem comes.

If I designate the engine as an engine that does not exist! This time MySQL can have two kinds of behavior to choose 1, direct error; 2. Replace the table's storage engine with InnoDB

Example:

1. Environment check (see MySQL supported storage engine, Sql_mode mode)

001: Storage engine, as can be seen on this MySQL does not support the federated engine

Mysql>show engines;+--------------------+---------+----------------------------------------------------------------+------------- -+------+------------+|Engine|Support|Comment|Transactions|Xa|Savepoints|+--------------------+---------+----------------------------------------------------------------+------------- -+------+------------+|MyISAM|YES|MyISAM Storage Engine|NO|NO|NO||Csv|YES|CSV Storage Engine|NO|NO|NO||Mrg_myisam|YES|Collection ofIdentical MyISAM tables|NO|NO|NO||Blackhole|YES| /Dev/NULLStorage engine (anything you write toIt disappears)|NO|NO|NO||MEMORY|YES|Hash based, storedinchMemory, useful for TemporaryTables|NO|NO|NO||Performance_schema|YES|PerformanceSchema                                             |NO|NO|NO||ARCHIVE|YES|Archive Storage Engine|NO|NO|NO||InnoDB| DEFAULT |Supports transactions, row- LevelLocking and ForeignKeys|YES|YES|YES||Federated|NO|Federated MySQL Storage Engine| NULL         | NULL | NULL       |+--------------------+---------+----------------------------------------------------------------+------------- -+------+------------+9Rowsinch Set(0.00Sec

002:sql_mode

Mysql>Show variables like 'Sql_mode';+---------------+---------------------+|Variable_name|Value|+---------------+---------------------+|Sql_mode|Strict_trans_tables|+---------------+---------------------+1Rowinch Set(0.00Sec

003: Test

Mysql> Create TableT (xint) engine=Federated; Query OK,0Rows affected,2Warnings (0.11sec) MySQL>ShowCreate TableT;+-------+--------------------------------------------------------------------------------------+| Table | Create Table                                                                         |+-------+--------------------------------------------------------------------------------------+|T| CREATE TABLE' t ' (' X 'int( One)DEFAULT NULL) ENGINE=InnoDBDEFAULTCHARSET=Latin1|+-------+--------------------------------------------------------------------------------------+1Rowinch Set(0.00sec) MySQL> 

Conclusion 001: when the Sql_mode does not contain no_engine_subtitution and the storage engine specified in CREATE TABLE is not supported, MySQL will change the engine of the table to InnoDB.

Example:

When Sql_mode has no_engine_subtitution,

Engine support situation:

Mysql>show engines;+--------------------+---------+----------------------------------------------------------------+------------- -+------+------------+|Engine|Support|Comment|Transactions|Xa|Savepoints|+--------------------+---------+----------------------------------------------------------------+------------- -+------+------------+|MyISAM|YES|MyISAM Storage Engine|NO|NO|NO||Csv|YES|CSV Storage Engine|NO|NO|NO||Mrg_myisam|YES|Collection ofIdentical MyISAM tables|NO|NO|NO||Blackhole|YES| /Dev/NULLStorage engine (anything you write toIt disappears)|NO|NO|NO||MEMORY|YES|Hash based, storedinchMemory, useful for TemporaryTables|NO|NO|NO||Performance_schema|YES|PerformanceSchema                                             |NO|NO|NO||ARCHIVE|YES|Archive Storage Engine|NO|NO|NO||InnoDB| DEFAULT |Supports transactions, row- LevelLocking and ForeignKeys|YES|YES|YES||Federated|NO|Federated MySQL Storage Engine| NULL         | NULL | NULL       |+--------------------+---------+----------------------------------------------------------------+------------- -+------+------------+9Rowsinch Set(0.00Sec

Sql_mode situation:

Mysql>Show variables like 'Sql_mode';+---------------+--------------------------------------------+|Variable_name|Value|+---------------+--------------------------------------------+|Sql_mode|Strict_trans_tables,no_engine_substitution|+---------------+--------------------------------------------+1Rowinch Set(0.00Sec

Test:

MySQL>createtableint) engine=1286 (42000  'Federated'

Conclusion 002: if the engine item specified when CREATE TABLE is not supported when Sql_mode includes No_engine_subtitution, MySQL will support the error.

MySQL Sql_mode's no_engine_substitution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.