mysql系统变量的坑,你入了吗?

sql_mode 定义了两个方面:MySQL应支持的SQL语法,以及应该在数据上执行何种确认检查。下面是参数的信息

SQL_MODE Values

不同的SQL_mode值是:

Option Description
ALLOW_INVALID_DATES Allow any day between 1-31 in the day part. This is convenient when you want to read in all (including wrong data) into the database and then manipulate it there.【让任何一天之间的1-31天的一部分.当您希望将所有内容(包括错误的数据)读入数据库并在数据库中进行操作时,这很方便。】
ANSI Changes the SQL syntax to be closer to ANSI SQL. Sets:

REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE

It also adds a restriction: an error will be returned if a subquery uses an aggregating function with a reference to a column from an outer query in a way that cannot be resolved. 【将SQL语法更改为更接近ANSISQL。Set:REAL_AS_FLOAT,PIPES_AS_CONTAT,ANSI_CAPTIONS,它还添加了一个限制:如果子查询使用引用外部查询的列的聚合函数,那么将返回一个错误,而这种方式是无法解决的。】
ANSI_QUOTES Changes " to be treated as `, the identifier quote character. This may break old MariaDB applications which assume that " is used as a string quote character.【更改“作为`,标识符引号字符。这可能会破坏那些假定“用作字符串引号字符”的老MariaDB应用程序。】
DB2 Same as:

PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, DB2, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS
 
EMPTY_STRING_IS_NULL Oracle-compatibility option that translates Item_string created in the parser to Item_null, and translates binding an empty string as prepared statement parameters to binding NULL. For example, SELECT '' IS NULL returns TRUE, INSERT INTO t1 VALUES ('') inserts NULL. Since MariaDB 10.3.3【甲骨文-兼容性选项,它将解析器中创建的Item_String转换为Item_NULL,并将绑定空字符串作为准备好的语句参数转换为绑定NULL。例如,选择“‘isNULL返回true,将INSERTINTO T1值(’)插入NULL】
ERROR_FOR_DIVISION_BY_ZERO If not set, division by zero returns NULL. If set, returns a warning as well. Also see MDEV-8319. Default since MariaDB 10.2.4.【如果没有设置,除以零将返回NULL。如果设置了,也返回一个警告。】
HIGH_NOT_PRECEDENCE Compatibility option for MySQL 5.0.1 and before; This changes NOT a BETWEEN b AND c to be parsed as (NOT a) BETWEEN a AND c【MySQL5.0.1及以前版本的兼容性选项;这不会改变b和c之间的a,并将其解析为a和c之间的(不是a)。
IGNORE_BAD_TABLE_OPTIONS If this is set generate a warning (not an error) for wrong table option in CREATE TABLE. Also, since 10.0.13, do not comment out these wrong table options in SHOW CREATE TABLE.【如果设置了此选项,则为CREATETABLE中的错误表选项生成警告(而不是错误)。此外,由于10.0.13,不要注释掉这些错误的表选项在显示创建表。】
IGNORE_SPACE Allow one to have spaces (including tab characters and new line characters) between function name and '('. The drawback is that this causes built in functions to become reserved words.
MAXDB Same as:

PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, MAXDB, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS, NO_AUTO_CREATE_USER
 
MSSQL Same as:

PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, MSSQL, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS
 
MYSQL323 Same as:

NO_FIELD_OPTIONS, HIGH_NOT_PRECEDENCE
 
MYSQL40 Same as:

NO_FIELD_OPTIONS, HIGH_NOT_PRECEDENCE
 
NO_AUTO_CREATE_USER Don't automatically create users with GRANT. Produce a 1133 error: "Can't find any matching row in the user table". Default since MariaDB 10.1.7.【不要使用GRANT自动创建用户。产生一个1133错误:“在User表中找不到任何匹配的行”】
NO_AUTO_VALUE_ON_ZERO If set don't generate an AUTO_INCREMENT on INSERT of zero in an AUTO_INCREMENT column. Normally both zero and NULL generate new AUTO_INCREMENT values.【如果没有设置,则不要在AUTO_INSERT列中的INSERT为0时生成AUTO_INSERT。通常,零和空都会生成新的AUTO_增量值。】
NO_BACKSLASH_ESCAPES Disables using the backslash character \ as an escape character within strings, making it equivalent to an ordinary character.
NO_DIR_IN_CREATE Ignore all INDEX DIRECTORY and DATA DIRECTORY directives when creating a table. Can be useful on slave replication servers.
NO_ENGINE_SUBSTITUTION If not set, if the available storage engine specified by a CREATE TABLE is not available, a warning is given and the default storage engine is used instead. If set, generate a 1286 error when creating a table if the specified storage engine is not available. See also enforce_storage_engine. Default since MariaDB 10.1.7.
NO_FIELD_OPTIONS Remove MariaDB-specific column options from the output of SHOW CREATE TABLE. This is also used by the portability mode of mysqldump.
NO_KEY_OPTIONS Remove MariaDB-specific index options from the output of SHOW CREATE TABLE. This is also used by the portability mode of mysqldump.
NO_TABLE_OPTIONS Remove MariaDB-specific table options from the output of SHOW CREATE TABLE. This is also used by the portability mode of mysqldump.
NO_UNSIGNED_SUBTRACTION When enabled, subtraction results are signed even if the operands are unsigned.
NO_ZERO_DATE Don't allow '000-00-00' as a valid date in strict mode (produce a 1525 error). Zero dates can be inserted with IGNORE. If not in strict mode, a warning is generated.
NO_ZERO_IN_DATE Don't allow dates where the year is not zero but the month or day parts of the date are zero (produce a 1525 error). For example, with this set, '0000-00-00' is allowed, but '1970-00-10' or '1929-01-00' are not. If the ignore option is used, MariaDB will insert '0000-00-00' for those types of dates. If not in strict mode, a warning is generated instead.
ONLY_FULL_GROUP_BY For SELECT ... GROUP BY queries, disallow SELECTing columns which are not referred to in the GROUP BY clause, unless they are passed to an aggregate function like COUNT() or MAX(). Produce a 1055 error.
ORACLE Sets sql_mode to:

PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, ORACLE, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS, NO_AUTO_CREATE_USER. From MariaDB 10.3, the server understands a large subset of Oracle's PL/SQL language instead of MariaDB's traditional syntax for stored routines. See SQL_MODE=ORACLE From MariaDB 10.3.
 
PAD_CHAR_TO_FULL_LENGTH Trailing spaces in CHAR columns are by default trimmed upon retrieval. With PAD_CHAR_TO_FULL_LENGTH enabled, no trimming occurs. Does not apply to VARCHARs.
PIPES_AS_CONCAT Allows using the pipe character (ASCII 124) as string concatenation operator. This means that "A" || "B" can be used in place of CONCAT("A", "B").
POSTGRESQL Same as:

PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, POSTGRESQL, NO_KEY_OPTIONS, NO_TABLE_OPTIONS, NO_FIELD_OPTIONS
 
REAL_AS_FLOAT REAL is a synonym for FLOAT rather than DOUBLE.
SIMULTANEOUS_ASSIGNMENT Setting this makes the SET part of the UPDATE statement evaluate all assignments simultaneously, not left-to-right. From MariaDB 10.3.5
STRICT_ALL_TABLES Strict mode. Statements with invalid or missing data are aborted and rolled back. For a non-transactional storage engine with a statement affecting multiple rows, this may mean a partial insert or update if the error is found in a row beyond the first.
STRICT_TRANS_TABLES Strict mode. Statements with invalid or missing data are aborted and rolled back, except that for non-transactional storage engines and statements affecting multiple rows where the invalid or missing data is not the first row, MariaDB will convert the invalid value to the closest valid value, or, if a value is missing, insert the column default value. Default since MariaDB 10.2.4.
TRADITIONAL Makes MariaDB work like a traditional SQL server. Same as:

STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, TRADITIONAL, NO_AUTO_CREATE_USER

max_allowed_packed:允许传输sql最大内容长度,Mysql默认是1024,也就是1M,有时就会碰到这样得情况,sql超出了最大值后,后面所有的语句都不行了,这时,我们就需要手动修改它得大小,详细请看详细请点这里

猜你喜欢

转载自blog.csdn.net/qq_38151921/article/details/81512096