The Server SQL ModeIn MySQL 4.0, a server SQL mode system variable named sql_mode was introduced to allow configuring certain aspects of how the server executes SQL statements. Initially, this variable could be set only by means of the --sql-mode startup option. As MySQL 4.1.1, the SQL mode also can be changed at runtime and individual clients can change the mode to affect their own connection. This means that any client can change how the server behaves in relation to itself without impact on other clients. The SQL mode affects behaviors such as identifier quoting and handling of invalid values during data entry. The following list describes a few of the possible mode values:
When you set the SQL mode, specify a value consisting of one or more mode values separated by commas, or an empty string to clear the value. Mode values are not case sensitive. To set the SQL mode when you start the server, use the --sql-mode option on the command line or in an option file: --sql-mode="ANSI" --sql-mode="ANSI_QUOTES,PIPES_AS_CONCAT" To change the SQL mode at runtime, set the sql_mode system variable with a SET statement:
To determine the current value of the session or global SQL mode, use these statements: SELECT @@SESSION.sql_mode; SELECT @@GLOBAL.sql_mode; The value returned consists of a comma-separated list of enabled modes, or an empty value if no modes are enabled. The full set of mode values is given in the description of the sql_mode variable in Appendix D, "System, Status, and User Variable Reference." For discussion of SQL mode values that affect handling of erroneous or missing values during data entry, see "How MySQL Handles Invalid Data Values," in Chapter 3. General background on system variables is provided in "Setting and Checking System Variable Values," in Chapter 11. |