📄 strict.test
字号:
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));--error 1292INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME));--error 1292INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME));# deactivated because of Bug#8294# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE#--error 1292#INSERT INTO t1 (col2) VALUES(CONVERT('2004-9-31 15:30',DATETIME));#--error 1292#INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-32 15:30',DATETIME));#--error 1292#INSERT INTO t1 (col2) VALUES(CONVERT('2003-02-29 15:30',DATETIME));#--error 1292#INSERT INTO t1 (col2) VALUES(CONVERT('2004-13-15 15:30',DATETIME));# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values--error 1292INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME));## Test INSERT with CONVERT to DATETIME into DATETIME# All test cases expected to fail should return # SQLSTATE 22007 <invalid datetime value>--error 1292INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME));-- should return OK-- We accept this to be a failure--error 1292INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME));--error 1292INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME));# deactivated because of Bug#8294# Bug#8294 Traditional: Misleading error message for invalid CAST to DATE#--error 1292#INSERT INTO t1 (col3) VALUES(CONVERT('2004-9-31 15:30',DATETIME));#--error 1292#INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-32 15:30',DATETIME));#--error 1292#INSERT INTO t1 (col3) VALUES(CONVERT('2003-02-29 15:30',DATETIME));#--error 1292#INSERT INTO t1 (col3) VALUES(CONVERT('2004-13-15 15:30',DATETIME));# Bug#6145: Traditional: CONVERT and CAST should reject zero DATE values--error 1292INSERT INTO t1 (col3) VALUES(CONVERT('0000-00-00',DATETIME));drop table t1;# Test INSERT with TINYINTCREATE TABLE t1(col1 TINYINT, col2 TINYINT UNSIGNED);INSERT INTO t1 VALUES(-128,0),(0,0),(127,255),('-128','0'),('0','0'),('127','255'),(-128.0,0.0),(0.0,0.0),(127.0,255.0);# Test that we restored the mode checking properly after an ok querySELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 2;-- error 1264INSERT INTO t1 (col1) VALUES(-129);-- error 1264INSERT INTO t1 (col1) VALUES(128);-- error 1264INSERT INTO t1 (col2) VALUES(-1);-- error 1264INSERT INTO t1 (col2) VALUES(256);-- error 1264INSERT INTO t1 (col1) VALUES('-129');-- error 1264INSERT INTO t1 (col1) VALUES('128');-- error 1264INSERT INTO t1 (col2) VALUES('-1');-- error 1264INSERT INTO t1 (col2) VALUES('256');-- error 1264INSERT INTO t1 (col1) VALUES(128.0);-- error 1264INSERT INTO t1 (col2) VALUES(-1.0);-- error 1264INSERT INTO t1 (col2) VALUES(256.0);SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 1;--error 1264UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;--error 1264UPDATE t1 SET col2=col2 + 50 WHERE col2 > 0;--error 1365UPDATE t1 SET col1=col1 / 0 WHERE col1 > 0;set @@sql_mode='ERROR_FOR_DIVISION_BY_ZERO';INSERT INTO t1 values (1/0,1/0);set @@sql_mode='ansi,traditional';SELECT MOD(col1,0) FROM t1 WHERE col1 > 0 LIMIT 2;# Should return SQLSTATE 22018 invalid character value for cast--error 1366INSERT INTO t1 (col1) VALUES ('');--error 1366INSERT INTO t1 (col1) VALUES ('a59b');--error 1265INSERT INTO t1 (col1) VALUES ('1a');INSERT IGNORE INTO t1 (col1) VALUES ('2a');INSERT IGNORE INTO t1 values (1/0,1/0);set @@sql_mode='ansi';INSERT INTO t1 values (1/0,1/0);set @@sql_mode='ansi,traditional';INSERT IGNORE INTO t1 VALUES('-129','-1'),('128','256');INSERT IGNORE INTO t1 VALUES(-129.0,-1.0),(128.0,256.0);UPDATE IGNORE t1 SET col2=1/NULL where col1=0;SELECT * FROM t1;DROP TABLE t1;# Test INSERT with SMALLINTCREATE TABLE t1(col1 SMALLINT, col2 SMALLINT UNSIGNED);INSERT INTO t1 VALUES(-32768,0),(0,0),(32767,65535),('-32768','0'),('32767','65535'),(-32768.0,0.0),(32767.0,65535.0);--error 1264INSERT INTO t1 (col1) VALUES(-32769);--error 1264INSERT INTO t1 (col1) VALUES(32768);--error 1264INSERT INTO t1 (col2) VALUES(-1);--error 1264INSERT INTO t1 (col2) VALUES(65536);--error 1264INSERT INTO t1 (col1) VALUES('-32769');--error 1264INSERT INTO t1 (col1) VALUES('32768');--error 1264INSERT INTO t1 (col2) VALUES('-1');--error 1264INSERT INTO t1 (col2) VALUES('65536');--error 1264INSERT INTO t1 (col1) VALUES(-32769.0);--error 1264INSERT INTO t1 (col1) VALUES(32768.0);--error 1264INSERT INTO t1 (col2) VALUES(-1.0);--error 1264INSERT INTO t1 (col2) VALUES(65536.0);--error 1264UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;--error 1264UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;--error 1365UPDATE t1 SET col1 = col1 / 0 WHERE col1 > 0;--error 1365UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;--error 1366INSERT INTO t1 (col1) VALUES ('');--error 1366INSERT INTO t1 (col1) VALUES ('a59b');--error 1265INSERT INTO t1 (col1) VALUES ('1a');INSERT IGNORE INTO t1 (col1) VALUES ('2a');INSERT IGNORE INTO t1 values (1/0,1/0);INSERT IGNORE INTO t1 VALUES(-32769,-1),(32768,65536);INSERT IGNORE INTO t1 VALUES('-32769','-1'),('32768','65536');INSERT IGNORE INTO t1 VALUES(-32769,-1.0),(32768.0,65536.0);UPDATE IGNORE t1 SET col2=1/NULL where col1=0;SELECT * FROM t1;DROP TABLE t1;# Test INSERT with MEDIUMINTCREATE TABLE t1 (col1 MEDIUMINT, col2 MEDIUMINT UNSIGNED);INSERT INTO t1 VALUES(-8388608,0),(0,0),(8388607,16777215),('-8388608','0'),('8388607','16777215'),(-8388608.0,0.0),(8388607.0,16777215.0);--error 1264INSERT INTO t1 (col1) VALUES(-8388609);--error 1264INSERT INTO t1 (col1) VALUES(8388608);--error 1264INSERT INTO t1 (col2) VALUES(-1);--error 1264INSERT INTO t1 (col2) VALUES(16777216);--error 1264INSERT INTO t1 (col1) VALUES('-8388609');--error 1264INSERT INTO t1 (col1) VALUES('8388608');--error 1264INSERT INTO t1 (col2) VALUES('-1');--error 1264INSERT INTO t1 (col2) VALUES('16777216');--error 1264INSERT INTO t1 (col1) VALUES(-8388609.0);--error 1264INSERT INTO t1 (col1) VALUES(8388608.0);--error 1264INSERT INTO t1 (col2) VALUES(-1.0);--error 1264INSERT INTO t1 (col2) VALUES(16777216.0);--error 1264UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;--error 1264UPDATE t1 SET col2 = col2 + 50 WHERE col2 > 0;--error 1365UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;--error 1365UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;--error 1366INSERT INTO t1 (col1) VALUES ('');--error 1366INSERT INTO t1 (col1) VALUES ('a59b');--error 1265INSERT INTO t1 (col1) VALUES ('1a');INSERT IGNORE INTO t1 (col1) VALUES ('2a');INSERT IGNORE INTO t1 values (1/0,1/0);INSERT IGNORE INTO t1 VALUES(-8388609,-1),(8388608,16777216);INSERT IGNORE INTO t1 VALUES('-8388609','-1'),('8388608','16777216');INSERT IGNORE INTO t1 VALUES(-8388609.0,-1.0),(8388608.0,16777216.0);UPDATE IGNORE t1 SET col2=1/NULL where col1=0;SELECT * FROM t1;DROP TABLE t1;# Test INSERT with INTCREATE TABLE t1 (col1 INT, col2 INT UNSIGNED);INSERT INTO t1 VALUES(-2147483648,0),(0,0),(2147483647,4294967295),('-2147483648','0'),('2147483647','4294967295'),(-2147483648.0,0.0),(2147483647.0,4294967295.0);--error 1264INSERT INTO t1 (col1) VALUES(-2147483649);--error 1264INSERT INTO t1 (col1) VALUES(2147643648);--error 1264INSERT INTO t1 (col2) VALUES(-1);--error 1264INSERT INTO t1 (col2) VALUES(4294967296);--error 1264INSERT INTO t1 (col1) VALUES('-2147483649');--error 1264INSERT INTO t1 (col1) VALUES('2147643648');--error 1264INSERT INTO t1 (col2) VALUES('-1');--error 1264INSERT INTO t1 (col2) VALUES('4294967296');--error 1264INSERT INTO t1 (col1) VALUES(-2147483649.0);--error 1264INSERT INTO t1 (col1) VALUES(2147643648.0);--error 1264INSERT INTO t1 (col2) VALUES(-1.0);--error 1264INSERT INTO t1 (col2) VALUES(4294967296.0);--error 1264UPDATE t1 SET col1 = col1 - 50 WHERE col1 < 0;--error 1264UPDATE t1 SET col2 =col2 + 50 WHERE col2 > 0;--error 1365UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;--error 1365UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;--error 1264INSERT INTO t1 (col1) VALUES ('');--error 1264INSERT INTO t1 (col1) VALUES ('a59b');--error 1265INSERT INTO t1 (col1) VALUES ('1a');INSERT IGNORE INTO t1 (col1) VALUES ('2a');INSERT IGNORE INTO t1 values (1/0,1/0);INSERT IGNORE INTO t1 values (-2147483649, -1),(2147643648,4294967296);INSERT IGNORE INTO t1 values ('-2147483649', '-1'),('2147643648','4294967296');INSERT IGNORE INTO t1 values (-2147483649.0, -1.0),(2147643648.0,4294967296.0);UPDATE IGNORE t1 SET col2=1/NULL where col1=0;SELECT * FROM t1;DROP TABLE t1;# Test INSERT with BIGINT# Note that this doesn't behave 100 % to standard as we rotate# integers when it's too big/small (just like C)CREATE TABLE t1 (col1 BIGINT, col2 BIGINT UNSIGNED);INSERT INTO t1 VALUES(-9223372036854775808,0),(0,0),(9223372036854775807,18446744073709551615);INSERT INTO t1 VALUES('-9223372036854775808','0'),('9223372036854775807','18446744073709551615');INSERT INTO t1 VALUES(-9223372036854774000.0,0.0),(9223372036854775700.0,1844674407370954000.0);--error 1264INSERT INTO t1 (col1) VALUES(-9223372036854775809);--error 1264INSERT INTO t1 (col1) VALUES(9223372036854775808);--error 1264INSERT INTO t1 (col2) VALUES(-1);--error 1264INSERT INTO t1 (col2) VALUES(18446744073709551616);--error 1264INSERT INTO t1 (col1) VALUES('-9223372036854775809');--error 1264INSERT INTO t1 (col1) VALUES('9223372036854775808');--error 1264INSERT INTO t1 (col2) VALUES('-1');--error 1264INSERT INTO t1 (col2) VALUES('18446744073709551616');# Note that the following two double numbers are slighty bigger than max/min# bigint becasue of rounding errors when converting it to bigint--error 1264INSERT INTO t1 (col1) VALUES(-9223372036854785809.0);--error 1264INSERT INTO t1 (col1) VALUES(9223372036854785808.0);--error 1264INSERT INTO t1 (col2) VALUES(-1.0);--error 1264INSERT INTO t1 (col2) VALUES(18446744073709551616.0);# The following doesn't give an error as it's done in integer context# UPDATE t1 SET col1=col1 - 5000 WHERE col1 < 0;# UPDATE t1 SET col2 =col2 + 5000 WHERE col2 > 0;--error 1365UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;--error 1365UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;--error 1264INSERT INTO t1 (col1) VALUES ('');--error 1264INSERT INTO t1 (col1) VALUES ('a59b');--error 1265INSERT INTO t1 (col1) VALUES ('1a');INSERT IGNORE INTO t1 (col1) VALUES ('2a');INSERT IGNORE INTO t1 values (1/0,1/0);INSERT IGNORE INTO t1 VALUES(-9223372036854775809,-1),(9223372036854775808,18446744073709551616);INSERT IGNORE INTO t1 VALUES('-9223372036854775809','-1'),('9223372036854775808','18446744073709551616');INSERT IGNORE INTO t1 VALUES(-9223372036854785809.0,-1.0),(9223372036854785808.0,18446744073709551616.0);UPDATE IGNORE t1 SET col2=1/NULL where col1=0;SELECT * FROM t1;DROP TABLE t1;# Test INSERT with NUMERICCREATE TABLE t1 (col1 NUMERIC(4,2));INSERT INTO t1 VALUES (10.55),(10.5555),(0),(-10.55),(-10.5555),(11),(1e+01);-- Note that the +/-10.5555 is inserted as +/-10.55, not +/-10.56 !INSERT INTO t1 VALUES ('10.55'),('10.5555'),('-10.55'),('-10.5555'),('11'),('1e+01');-- The 2 following inserts should generate a warning, but doesn't yet-- because NUMERIC works like DECIMAL--error 1264INSERT INTO t1 VALUES (101.55);--error 1264INSERT INTO t1 VALUES (101);--error 1264INSERT INTO t1 VALUES (-101.55);--error 1264INSERT INTO t1 VALUES (1010.55);--error 1264INSERT INTO t1 VALUES (1010);-- The 2 following inserts should generate a warning, but doesn't yet-- because NUMERIC works like DECIMAL--error 1264INSERT INTO t1 VALUES ('101.55');--error 1264INSERT INTO t1 VALUES ('101');--error 1264INSERT INTO t1 VALUES ('-101.55');--error 1264INSERT INTO t1 VALUES ('-1010.55');--error 1264INSERT INTO t1 VALUES ('-100E+1');--error 1366INSERT INTO t1 VALUES ('-100E');--error 1264UPDATE t1 SET col1 =col1 * 50000 WHERE col1 =11;--error 1365UPDATE t1 SET col1 =col1 / 0 WHERE col1 > 0;--error 1365UPDATE t1 SET col1= MOD(col1,0) WHERE col1 > 0;#--error 1265--error 1366INSERT INTO t1 (col1) VALUES ('');#--error 1265--error 1366INSERT INTO t1 (col1) VALUES ('a59b');--error 1366INSERT INTO t1 (col1) VALUES ('1a');INSERT IGNORE INTO t1 (col1) VALUES ('2a');INSERT IGNORE INTO t1 values (1/0);INSERT IGNORE INTO t1 VALUES(1000),(-1000);INSERT IGNORE INTO t1 VALUES('1000'),('-1000');INSERT IGNORE INTO t1 VALUES(1000.0),(-1000.0);UPDATE IGNORE t1 SET col1=1/NULL where col1=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -