Created
December 15, 2016 20:06
-
-
Save bradfordpythian/c17828e8df603c14b1fe315ae4ff224d to your computer and use it in GitHub Desktop.
Test showing how MySQL sql_mode STRICT_TRANS_TABLE fails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE SCHEMA IF NOT EXISTS test; | |
USE test; | |
DROP TABLE IF EXISTS strict_test; | |
CREATE TABLE strict_test( | |
i1 INT UNSIGNED NOT NULL AUTO_INCREMENT, | |
c1 VARCHAR(10) NOT NULL, | |
i2 TINYINT NOT NULL DEFAULT '1', | |
PRIMARY KEY (i1) | |
) ENGINE=InnoDB; | |
SET GLOBAL sql_mode='NO_ENGINE_SUBSTITUTION'; | |
\r | |
SELECT @@sql_mode; | |
INSERT INTO strict_test(i2) VALUES(2); | |
SHOW WARNINGS; | |
SELECT * FROM strict_test; | |
SET GLOBAL sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'; | |
\r | |
SELECT @@sql_mode; | |
INSERT INTO strict_test(i2) VALUES(3); | |
SELECT * FROM strict_test; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment