IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    MySQL隐式转换

    royalwzy发表于 2015-08-09 09:57:39
    love 0
    mysql> create table users(num int not null, id varchar(30) not null, password varchar(30) not null, primary key(num)); Query OK, 0 rows affected (0.00 sec) mysql> insert into users values(1, 'admin', 'ad1234'); Query OK, 1 row affected (0.00 sec) mysql> insert into users values(2, 'wh1ant', 'wh1234'); Query OK, 1 row affected (0.00 sec) mysql> insert into users values(3, 'secuholic', 'se1234'); Query OK, 1 row affected (0.00 sec) mysql> select * from users where id=0; +-----+-----------+----------+ | num | id        | password | +-----+-----------+----------+ |   1 | admin     | ad1234   | |   2 | wh1ant    | wh1234   | |   3 | secuholic | se1234   | +-----+-----------+----------+ 3 rows in set, 3 warnings (0.00 sec) mysql> show warnings -> ; +---------+------+-----------------------------------------------+ | Level   | Code | Message                                       | +---------+------+-----------------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: 'admin'     | | Warning | 1292 | Truncated incorrect DOUBLE value: 'wh1ant'    | | Warning | 1292 | Truncated incorrect DOUBLE value: 'secuholic' | +---------+------+-----------------------------------------------+ 3 rows in set (0.00 sec) mysql> select * from users where id='0'; Empty set (0.00 sec) mysql> select * from users where 0=id; +-----+-----------+----------+ | num | id        | password | +-----+-----------+----------+ |   1 | admin     | ad1234   | |   2 | wh1ant    | wh1234   | |   3 | secuholic | se1234   | +-----+-----------+----------+ 3 rows in set, 3 warnings (0.00 sec) mysql> insert into users values('ucjmh','ucjmh','ucjmh'); Query OK, 1 row affected, 1 warning (0.00 sec) mysql> show warnings; +---------+------+------------------------------------------------------------+ | Level   | Code | Message                                                    | +---------+------+------------------------------------------------------------+ | Warning | 1366 | Incorrect integer value: 'ucjmh' for column 'num' at row 1 | +---------+------+------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select * from users; +-----+-----------+----------+ | num | id        | password | +-----+-----------+----------+ |   0 | ucjmh     | ucjmh    | |   1 | admin     | ad1234   | |   2 | wh1ant    | wh1234   | |   3 | secuholic | se1234   | +-----+-----------+----------+ 4 rows in set (0.00 sec)
    如果是在oracle中直接会报ora-01722


沪ICP备19023445号-2号
友情链接