重新创建SQL:
drop table t1;
set sql_mode = '';
create table t1 (c1 int, c2 int);
set sql_warnings = 0;
SHOW VARIABLES LIKE '%sql_warnings%';
insert into t1 values(1,'b');
set sql_warnings = 1;
SHOW VARIABLES LIKE '%sql_warnings%';
insert into t1 values(1,'b');
输出:
mysql> create table t1 (c1 int, c2 int);
Query OK, 0 rows affected (0.01 sec)
mysql> set sql_warnings = 0;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE '%sql_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_warnings | OFF |
+---------------+-------+
1 row in set, 1 warning (0.01 sec)
mysql> insert into t1 values(1,'b');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql>
mysql> set sql_warnings = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE '%sql_warnings%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| sql_warnings | ON |
+---------------+-------+
1 row in set, 1 warning (0.00 sec)
mysql> insert into t1 values(1,'b');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.8-rc |
+-----------+
1 row in set (0.00 sec)
从输出中,无论将sql_warnings设置为0还是1,我总是在INSERT语句中收到警告。 谁知道为什么?
更新
&#34>显示变量的结果'%sql_warnings%';"在上面添加。
答案 0 :(得分:1)