MySQL SQL模式介紹
MySQL伺服器能夠在執行在不同的SQL模式下,並且能在不同客戶端下設定不同的SQL模式,可以透過sql_mode系統引數來設定SQL模式。
SQL模式會影響MySQL支援的SQL語法和資料的驗證。
MariaDB [test]> select @@sql_mode;
+--------------------------------------------+
| @@sql_mode |
+--------------------------------------------+
| NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.08 sec)
NO_AUTO_CREATE_USER
防止透過GRANT語句建立沒有密碼的資料庫賬戶。在透過GRANT建立使用者時,必須在IDENTIFIED BY後指定非空的密碼。建議使用CREATE USER語句建立資料庫賬戶,儘量避免使用GRANT語句來建立資料庫賬戶。
NO_ENGINE_SUBSTITUTION
當執行CREATE TABLE 或 ALTER TABLE語句,指定了一個不支援或沒有編譯的儲存引擎時,控制如何自動替換預設的儲存引擎。
當NO_ENGINE_SUBSTITUTION引數沒有啟用時,對於CREATE TABLE語句,如果指定的儲存引擎不可用,會使用預設的儲存,且會產生一個警告。對於ALTER TABLE語句,會產生一個警告,且表的儲存引擎轉化失敗。
當NO_ENGINE_SUBSTITUTION引數啟用時,如果指定的儲存引擎不可用,會發生報錯,且表不會建立或更改成功。
--最重要的SQL模式
ANSI
這個模式改變SQL的語法和行為以更接近標準的SQL。
STRICT_TRANS_TABLES
如果值不能插入到事務表中,則退出這條語句;對於非事務表,如果插入或更新的值發生在一行的SQL或多行語句的第一行中,則退出語句。
TRADITIONAL
當插入一個錯誤的值到一列中時,MySQL會報錯而不是警告。
--SQL模式的結合
有一些特殊的SQL模式是一些SQL結合在一起的縮寫
例如,ANSI是REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE,ONLY_FULL_GROUP_BY(MySQL 5.7.5)模式的結合;
DB2是PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS模式的結合。
--嚴格SQL模式
嚴格模式控制MySQL如何處理資料改變SQL語句(例如INSERT或UPDATE)中無效或丟失的值。插入或更新的值無效有許多原因,例如,有可能因為欄位的資料型別,或值超過了欄位的最大範圍值。對於一個非空欄位,當要插入的一個值為空,且沒有預設值,這是值丟失。嚴格模式也會影響DDL語句,例如CREATE TABLE。
如果嚴格模式沒有生效,對於無效或丟失的值,MySQL會插入調整的值。在嚴格模式下,可以透過INSERT IGNORE或UPDATE IGNORE語句來跳過錯誤。
在嚴格模式下,對於類似SELECT這樣不改變資料的語句,無效的值會產生一個警告,而不是錯誤。在嚴格模式下,對於插入或更新超過欄位最大長度的值,會產生一個錯誤;而在非嚴格模式下,會產生一個警告,並將截斷後的值插入或更新到表中。
嚴格模式不會影響是否外來鍵驗證。可以透過foreign_key_checks引數來驗證外來鍵。
MariaDB [test]> show variables like '%foreign%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| foreign_key_checks | ON |
+--------------------+-------+
1 row in set (0.00 sec)
--示例①
嚴格SQL模式
MariaDB [test]> select @@sql_mode;
+--------------------------------------------+
| @@sql_mode |
+--------------------------------------------+
| NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.08 sec)
MariaDB [test]> create table t (name varchar(20), email varchar(40));
Query OK, 0 rows affected (0.21 sec)
MariaDB [test]> insert into t values('1234567890000000000000000000','fire beijing @ hotmail.com');
Query OK, 1 row affected, 1 warning (0.00 sec)
MariaDB [test]> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1265 | Data truncated for column 'name' at row 1 |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> select * from t;
+----------------------+----------------------------+
| name | email |
+----------------------+----------------------------+
| 12345678900000000000 | fire beijing @ hotmail.com |
+----------------------+----------------------------+
1 row in set (0.00 sec)
MariaDB [test]> set session sql_mode='STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@sql_mode;
+---------------------+
| @@sql_mode |
+---------------------+
| STRICT_TRANS_TABLES |
+---------------------+
1 row in set (0.00 sec)
MariaDB [test]> insert into t values('1234567890000000000000000000','fire beijing @ hotmail.com');
ERROR 1406 (22001): Data too long for column 'name' at row 1
--示例②
ANSI模式和傳統模式的區別
MariaDB [test]> set session sql_mode='ANSI';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@sql_mode;
+-------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.13 sec)
MariaDB [test]> create table t(d datetime);
Query OK, 0 rows affected (0.21 sec)
MariaDB [test]> insert into t values('2007-04-31');
Query OK, 1 row affected, 1 warning (0.01 sec)
MariaDB [test]> select * from t;
+---------------------+
| d |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
MariaDB [test]> set session sql_mode='TRADITIONAL';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@sql_mode;
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| @@sql_mode |
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> insert into t values('2007-04-31');
ERROR 1292 (22007): Incorrect datetime value: '2007-04-31' for column 'd' at row 1
--示例③
ANSI模式和傳統模式的對比
MariaDB [test]> set sql_mode='ANSI';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.11 sec)
MariaDB [test]> create table t(i int);
Query OK, 0 rows affected (0.45 sec)
MariaDB [test]> insert into t values(9%0);
Query OK, 1 row affected (0.08 sec)
MariaDB [test]> select * from t;
+------+
| i |
+------+
| NULL |
+------+
1 row in set (0.00 sec)
MariaDB [test]> set session sql_mode='TRADITIONAL';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> insert into t values(9%0);
ERROR 1365 (22012): Division by 0
--示例④
使反斜線稱為普通字元
MariaDB [test]> set sql_mode='ansi';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@global.sql_mode;
+--------------------------------------------+
| @@global.sql_mode |
+--------------------------------------------+
| NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> select @@session.sql_mode;
+-------------------------------------------------------------+
| @@session.sql_mode |
+-------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> select @@sql_mode;
+-------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.14 sec)
MariaDB [test]> create table t (context varchar(20));
Query OK, 0 rows affected (0.17 sec)
MariaDB [test]> insert into t values('\beijing');
Query OK, 1 row affected (0.07 sec)
MariaDB [test]> select * from t;
+---------+
| context |
+---------+
|eijing |
+---------+
1 row in set (0.00 sec)
MariaDB [test]> insert into t values('\\beijing');
Query OK, 1 row affected (0.11 sec)
MariaDB [test]> select * from t;
+----------+
| context |
+----------+
|eijing |
| \beijing |
+----------+
2 rows in set (0.00 sec)
MariaDB [test]> set sql_mode='REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,NO_BACKSLASH_ESCAPES';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> insert into t values('\\beijing');
Query OK, 1 row affected (0.00 sec)
MariaDB [test]> select * from t;
+-----------+
| context |
+-----------+
|eijing |
| \beijing |
| \\beijing |
+-----------+
3 rows in set (0.00 sec)
--示例⑤
ANSI模式包含了PIPES_AS_CONCAT模式,會將||視為連線運算子
MariaDB [test]> set sql_mode='ansi';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@session.sql_mode;
+-------------------------------------------------------------+
| @@session.sql_mode |
+-------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> select 'beijing'||'2008';
+-------------------+
| 'beijing'||'2008' |
+-------------------+
| beijing2008 |
+-------------------+
1 row in set (0.00 sec)
MariaDB [test]> set sql_mode='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select 'beijing'||'2008';
+-------------------+
| 'beijing'||'2008' |
+-------------------+
| 1 |
+-------------------+
1 row in set, 2 warnings (0.02 sec)
MariaDB [test]> show warnings;
+---------+------+----------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'beijing' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'beijing' |
+---------+------+----------------------------------------------+
2 rows in set (0.00 sec)
--示例⑥
在將MySQL資料庫遷移到其他資料時,可以設定sql_mode為NO_TABLE_OPTIONS模式,這樣可以去掉engine關鍵字
MariaDB [test]> show create table t;
+-------+----------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`context` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> set session sql_mode='NO_TABLE_OPTIONS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> show create table t;
+-------+-----------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------+
| t | CREATE TABLE `t` (
`context` varchar(20) DEFAULT NULL
) |
+-------+-----------------------------------------------------------+
1 row in set (0.00 sec)
SQL模式會影響MySQL支援的SQL語法和資料的驗證。
MariaDB [test]> select @@sql_mode;
+--------------------------------------------+
| @@sql_mode |
+--------------------------------------------+
| NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.08 sec)
NO_AUTO_CREATE_USER
防止透過GRANT語句建立沒有密碼的資料庫賬戶。在透過GRANT建立使用者時,必須在IDENTIFIED BY後指定非空的密碼。建議使用CREATE USER語句建立資料庫賬戶,儘量避免使用GRANT語句來建立資料庫賬戶。
NO_ENGINE_SUBSTITUTION
當執行CREATE TABLE 或 ALTER TABLE語句,指定了一個不支援或沒有編譯的儲存引擎時,控制如何自動替換預設的儲存引擎。
當NO_ENGINE_SUBSTITUTION引數沒有啟用時,對於CREATE TABLE語句,如果指定的儲存引擎不可用,會使用預設的儲存,且會產生一個警告。對於ALTER TABLE語句,會產生一個警告,且表的儲存引擎轉化失敗。
當NO_ENGINE_SUBSTITUTION引數啟用時,如果指定的儲存引擎不可用,會發生報錯,且表不會建立或更改成功。
--最重要的SQL模式
ANSI
這個模式改變SQL的語法和行為以更接近標準的SQL。
STRICT_TRANS_TABLES
如果值不能插入到事務表中,則退出這條語句;對於非事務表,如果插入或更新的值發生在一行的SQL或多行語句的第一行中,則退出語句。
TRADITIONAL
當插入一個錯誤的值到一列中時,MySQL會報錯而不是警告。
--SQL模式的結合
有一些特殊的SQL模式是一些SQL結合在一起的縮寫
例如,ANSI是REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE,ONLY_FULL_GROUP_BY(MySQL 5.7.5)模式的結合;
DB2是PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS模式的結合。
--嚴格SQL模式
嚴格模式控制MySQL如何處理資料改變SQL語句(例如INSERT或UPDATE)中無效或丟失的值。插入或更新的值無效有許多原因,例如,有可能因為欄位的資料型別,或值超過了欄位的最大範圍值。對於一個非空欄位,當要插入的一個值為空,且沒有預設值,這是值丟失。嚴格模式也會影響DDL語句,例如CREATE TABLE。
如果嚴格模式沒有生效,對於無效或丟失的值,MySQL會插入調整的值。在嚴格模式下,可以透過INSERT IGNORE或UPDATE IGNORE語句來跳過錯誤。
在嚴格模式下,對於類似SELECT這樣不改變資料的語句,無效的值會產生一個警告,而不是錯誤。在嚴格模式下,對於插入或更新超過欄位最大長度的值,會產生一個錯誤;而在非嚴格模式下,會產生一個警告,並將截斷後的值插入或更新到表中。
嚴格模式不會影響是否外來鍵驗證。可以透過foreign_key_checks引數來驗證外來鍵。
MariaDB [test]> show variables like '%foreign%';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| foreign_key_checks | ON |
+--------------------+-------+
1 row in set (0.00 sec)
--示例①
嚴格SQL模式
MariaDB [test]> select @@sql_mode;
+--------------------------------------------+
| @@sql_mode |
+--------------------------------------------+
| NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.08 sec)
MariaDB [test]> create table t (name varchar(20), email varchar(40));
Query OK, 0 rows affected (0.21 sec)
MariaDB [test]> insert into t values('1234567890000000000000000000','fire beijing @ hotmail.com');
Query OK, 1 row affected, 1 warning (0.00 sec)
MariaDB [test]> show warnings;
+---------+------+-------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------+
| Warning | 1265 | Data truncated for column 'name' at row 1 |
+---------+------+-------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> select * from t;
+----------------------+----------------------------+
| name | email |
+----------------------+----------------------------+
| 12345678900000000000 | fire beijing @ hotmail.com |
+----------------------+----------------------------+
1 row in set (0.00 sec)
MariaDB [test]> set session sql_mode='STRICT_TRANS_TABLES';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@sql_mode;
+---------------------+
| @@sql_mode |
+---------------------+
| STRICT_TRANS_TABLES |
+---------------------+
1 row in set (0.00 sec)
MariaDB [test]> insert into t values('1234567890000000000000000000','fire beijing @ hotmail.com');
ERROR 1406 (22001): Data too long for column 'name' at row 1
--示例②
ANSI模式和傳統模式的區別
MariaDB [test]> set session sql_mode='ANSI';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@sql_mode;
+-------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.13 sec)
MariaDB [test]> create table t(d datetime);
Query OK, 0 rows affected (0.21 sec)
MariaDB [test]> insert into t values('2007-04-31');
Query OK, 1 row affected, 1 warning (0.01 sec)
MariaDB [test]> select * from t;
+---------------------+
| d |
+---------------------+
| 0000-00-00 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
MariaDB [test]> set session sql_mode='TRADITIONAL';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@sql_mode;
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| @@sql_mode |
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> insert into t values('2007-04-31');
ERROR 1292 (22007): Incorrect datetime value: '2007-04-31' for column 'd' at row 1
--示例③
ANSI模式和傳統模式的對比
MariaDB [test]> set sql_mode='ANSI';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.11 sec)
MariaDB [test]> create table t(i int);
Query OK, 0 rows affected (0.45 sec)
MariaDB [test]> insert into t values(9%0);
Query OK, 1 row affected (0.08 sec)
MariaDB [test]> select * from t;
+------+
| i |
+------+
| NULL |
+------+
1 row in set (0.00 sec)
MariaDB [test]> set session sql_mode='TRADITIONAL';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> insert into t values(9%0);
ERROR 1365 (22012): Division by 0
--示例④
使反斜線稱為普通字元
MariaDB [test]> set sql_mode='ansi';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@global.sql_mode;
+--------------------------------------------+
| @@global.sql_mode |
+--------------------------------------------+
| NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> select @@session.sql_mode;
+-------------------------------------------------------------+
| @@session.sql_mode |
+-------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> select @@sql_mode;
+-------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> drop table t;
Query OK, 0 rows affected (0.14 sec)
MariaDB [test]> create table t (context varchar(20));
Query OK, 0 rows affected (0.17 sec)
MariaDB [test]> insert into t values('\beijing');
Query OK, 1 row affected (0.07 sec)
MariaDB [test]> select * from t;
+---------+
| context |
+---------+
|eijing |
+---------+
1 row in set (0.00 sec)
MariaDB [test]> insert into t values('\\beijing');
Query OK, 1 row affected (0.11 sec)
MariaDB [test]> select * from t;
+----------+
| context |
+----------+
|eijing |
| \beijing |
+----------+
2 rows in set (0.00 sec)
MariaDB [test]> set sql_mode='REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,NO_BACKSLASH_ESCAPES';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> insert into t values('\\beijing');
Query OK, 1 row affected (0.00 sec)
MariaDB [test]> select * from t;
+-----------+
| context |
+-----------+
|eijing |
| \beijing |
| \\beijing |
+-----------+
3 rows in set (0.00 sec)
--示例⑤
ANSI模式包含了PIPES_AS_CONCAT模式,會將||視為連線運算子
MariaDB [test]> set sql_mode='ansi';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select @@session.sql_mode;
+-------------------------------------------------------------+
| @@session.sql_mode |
+-------------------------------------------------------------+
| REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI |
+-------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> select 'beijing'||'2008';
+-------------------+
| 'beijing'||'2008' |
+-------------------+
| beijing2008 |
+-------------------+
1 row in set (0.00 sec)
MariaDB [test]> set sql_mode='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> select 'beijing'||'2008';
+-------------------+
| 'beijing'||'2008' |
+-------------------+
| 1 |
+-------------------+
1 row in set, 2 warnings (0.02 sec)
MariaDB [test]> show warnings;
+---------+------+----------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'beijing' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'beijing' |
+---------+------+----------------------------------------------+
2 rows in set (0.00 sec)
--示例⑥
在將MySQL資料庫遷移到其他資料時,可以設定sql_mode為NO_TABLE_OPTIONS模式,這樣可以去掉engine關鍵字
MariaDB [test]> show create table t;
+-------+----------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------+
| t | CREATE TABLE `t` (
`context` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [test]> set session sql_mode='NO_TABLE_OPTIONS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> show create table t;
+-------+-----------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------+
| t | CREATE TABLE `t` (
`context` varchar(20) DEFAULT NULL
) |
+-------+-----------------------------------------------------------+
1 row in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2121424/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MYSQL的安全模式:sql_safe_updates介紹MySql模式
- mysql中SQL的概念介紹MySql
- mysql SQL Layer各個模組介紹MySql
- 模式介紹模式
- MySql介紹MySql
- Sql索引介紹SQL索引
- MySQL SQL模式MySql模式
- MySQL MVCC介紹MySqlMVC
- mysql MVCC 介紹MySqlMVC
- MySQL索引介紹MySql索引
- MySQL MHA介紹MySql
- SQL Plan Management介紹SQL
- 設計模式:介紹設計模式
- 觀察者模式介紹模式
- LAMP架構介紹、MYSQL介紹、安裝LAMP架構MySql
- LAMP架構(LAMP介紹,mysql/mariaDB介紹,Mysql安裝)LAMP架構MySql
- MYSQL SET型別欄位的SQL操作知識介紹MySql型別
- MySQL表與表之間的SQL Joins圖介紹MySql
- MySQL檢視介紹MySql
- MySQL 安裝介紹MySql
- MySQL Binlog 介紹MySql
- MySQL分支版本介紹MySql
- MySQL group replication介紹MySql
- 【MySQL】mydumper工具介紹MySql
- 【Mysql】index extensions介紹MySqlIndex
- MySQL分割槽介紹MySql
- MySQL 5.5 mysqlimport介紹MySqlImport
- Amoeba for MySQL 基本介紹MySql
- SQL Server profiler 介紹2SQLServer
- SQL JOIN 簡單介紹SQL
- SQL Server xtype的介紹SQLServer
- 精妙SQL語句介紹SQL
- CSS設計模式介紹CSS設計模式
- 重構模式(一)---- 介紹模式
- 雲設計模式介紹設計模式
- SQL高手篇:精妙SQL語句介紹SQL
- Sql介紹 與 Sql基礎查詢SQL
- MySQL 8.0 目錄介紹MySql