Differences

This shows you the differences between two versions of the page.

mysql:sql_mode [December 12, 2011 1:29 pm]
sqlines
mysql:sql_mode [December 12, 2011 1:31 pm] (current)
sqlines
Line 1: Line 1:
 +====== MySQL sql_mode - Get and Set sql_mode (Strict Mode) Settings ======
 +MySQL //sql_mode// option defines supported SQL syntax, and data validation performed by MySQL.
 +
 +| **Syntax** | **SET** [**GLOBAL**%%|%%**SESSION**] sql_mode='//mode1,mode2, ...//' |
 +| **Quick Example** | SET sql_mode = 'ANSI_QUOTES,PIPES_AS_CONCAT'; |
 +| **Strict Mode** | When STRICT_TRANS_TABLES or STRICT_ALL_TABLES is specified |
 +| **MySQL Configuration** | You can set sql_mode in //my.cnf// (Unix), //my.ini// (Windows), or %%--%%//sql-mode// (command line) |
 +
 +===== Get and Set sql_mode =====
 +
 +Retrieving the current value of //sql_mode//:
 +
 +<code sql>
 +   -- Get the current value that could be already modified by SET sql_mode statement
 +   -- executed in the current session
 +   SELECT @@sql_mode;
 +  
 +   -- Get the global value, not affected by SET sql_mode
 +   SELECT @@GLOBAL.sql_mode;
 +</code>
 +
 +Change the current //sql_mode//:
 +
 +<code sql>
 +   SET sql_mode='STRICT_TRANS_TABLES,ANSI_QUOTES';
 +</code>
 +
 +===== Resources =====
 +
 +  * [[/mysql|MySQL Reference]]
 +  * [[http://dev.mysql.com/doc/refman/5.6/en/server-sql-mode.html|Server SQL Modes - MySQL 5.6 Reference Manual]]
 +
 +~~NOTOC~~