Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see the specific value of the sql_mode?

Tags:

mysql

There are some sql_mode values in MySQL:

ANSI,

IGNORE_SPACE,

STRICT_TRANS_TABLES, etc

How can I see the one particular value? The manual says:

You can retrieve the current mode by issuing a SELECT @@sql_mode statement.

But it just shows nothing, just one blank field in a table with @@sql_mode as a column name.

like image 592
Green Avatar asked May 14 '12 21:05

Green


People also ask

How do I view SQL mode?

To set the SQL mode at server startup, use the --sql-mode=" modes " option on the command line, or sql-mode=" modes " in an option file such as my. cnf (Unix operating systems) or my. ini (Windows). modes is a list of different modes separated by commas.

What is sql_mode?

SQL mode (sql_mode) is a MySQL system variable. By means of this varriable the MySQL Server SQL mode is controlled. Many operational characteristics of MySQL Server can be configured by setting the SQL mode.

How do I view SQL mode in MySQL?

To determine the current value of the session or global SQL mode, use these statements: SELECT @@SESSION. sql_mode; SELECT @@GLOBAL.

What is set sql_mode No_auto_value_on_zero?

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”; happens when different version of mysql is being used. When you are transfering from one server to another you should keep in mind the versions of database use in a new environment especially the mysql.


1 Answers

It's only blank for you because you have not set the sql_mode. If you set it, then that query will show you the details:

mysql> SELECT @@sql_mode; +------------+ | @@sql_mode | +------------+ |            | +------------+ 1 row in set (0.00 sec)  mysql> set sql_mode=ORACLE; Query OK, 0 rows affected (0.00 sec)  mysql> SELECT @@sql_mode; +----------------------------------------------------------------------------------------------------------------------+ | @@sql_mode                                                                                                           | +----------------------------------------------------------------------------------------------------------------------+ | PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ORACLE,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS,NO_AUTO_CREATE_USER | +----------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) 
like image 69
Ike Walker Avatar answered Nov 07 '22 23:11

Ike Walker