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:

   -- 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;

Change the current sql_mode:

   SET sql_mode='STRICT_TRANS_TABLES,ANSI_QUOTES';

Resources