Details
Description
This script:
DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (10.1)
produces no warnings or notes though truncation happens.
The DECIMAL data type in the same scenario does produce a note:
DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a DECIMAL(10,0)); INSERT INTO t1 VALUES (10.1); SHOW WARNINGS;
+-------+------+----------------------------------------+ | Level | Code | Message | +-------+------+----------------------------------------+ | Note | 1265 | Data truncated for column 'a' at row 1 | +-------+------+----------------------------------------+
CAST from DECIMAL to INT on SELECT also does not produce warnings:
DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a DECIMAL(10,1)); INSERT INTO t1 VALUES (10.1); SELECT CAST(a AS SIGNED) FROM t1;
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Repeatable in MySQL-5.7