3
mysql> CREATE TABLE foo ( f ENUM('a', '123') );

mysql> insert into foo(f) value(3);
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> select * from foo;
+------+
| f    |
+------+
|      |
+------+

How to make it produce a failure when inserting a value out of range?

0

2 Answers 2

5

From 10.4.4. The ENUM Type

If strict SQL mode is enabled, attempts to insert invalid ENUM values result in an error.

Sign up to request clarification or add additional context in comments.

2 Comments

To check our current SQL mode at the mysql prompt type SELECT @@global.sql_mode;. To change the current SQL mode to strict type type SET @@global.sql_mode = “STRICT_ALL_TABLES”;
what is your warning? i copied your code, and I get an error message: "#1265 - Data truncated for column 'f' at row 1". The record is NOT inserted! My global sql mode is STRICT_TRANS_TABLES.
1

This appears to be bug with mysql: http://bugs.mysql.com/bug.php?id=43880

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.