Home >Database >Mysql Tutorial >Windows与Linux下MySQL的细小区别

Windows与Linux下MySQL的细小区别

WBOY
WBOYOriginal
2016-06-07 16:52:171364browse

今天调程序的时候发现的的点小东西.在Windows下,如果键值为default null 插入

今天调程序的时候发现的的点小东西.

在Windows下,如果键值为default null 插入 '' 会有错误

而如果mysql工作在Linux 下,同样的表格,则会将其值为 0值 具体如下:

建表语句相同,在win与Linux下各建一个表

create table test(
a int(11),
b char(11),
c varchar(20));

window下执行如下语句及相应结果:

mysql> insert into test set a='';
ERROR 1366 (HY000): Incorrect integer value: '' for column 'a' at row 1
mysql> insert into test set a='a';
ERROR 1366 (HY000): Incorrect integer value: 'a' for column 'a' at row 1

mysql> insert into test set a='1';
Query OK, 1 row affected (0.02 sec)

mysql> select * from test;
+------+------+------+
| a | b | c |
+------+------+------+
| 1 | NULL | NULL |
+------+------+------+

Linux下执行如下语句及相应结果

mysql> insert into test set a='';
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> insert into test set a='a';
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from test;
+------+------+------+
| a | b | c |
+------+------+------+
| 0 | NULL | NULL |
| 0 | NULL | NULL |
+------+------+------+

发现在Windows下,不符合int类型的无法插入,而在Linux下,则将其转换为 0值存放

在Widnows下执行 select * from Test 与select * from TEsT 都是从test表取数据.

而在Linux下则会提示找不到Test或TEsT Linux是大小写敏感的.

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn