[mysql] How can I see the specific value of the sql_mode?

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.

This question is related to mysql

The answer is


You can also try this to determine the current global sql_mode value:

SELECT @@GLOBAL.sql_mode;

or session sql_mode value:

SELECT @@SESSION.sql_mode;

I also had the feeling that the SQL mode was indeed empty.


You need to login to your mysql terminal first using mysql -u username -p password

Then use this:

SELECT @@sql_mode; or SELECT @@GLOBAL.sql_mode;

output will be like this:

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

You can also set sql mode by this:

SET GLOBAL sql_mode=TRADITIONAL;