I am astounded that MySQL silently truncates your data if the column isn't wide enough. I had to see it to believe it, so I connected to the instance running on my machine and tried a little example. Sure enough:
mysql> describe x;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| y | char(3) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)
mysql> insert into x values ('abcd');
Query OK, 1 row affected (0.00 sec)
mysql> select y from x;
+------+
| y |
+------+
| abc |
+------+
1 row in set (0.03 sec)
I am particularly offended by the message Query OK, when it clearly isn't. In what universe is it acceptable for a database - an application centered on the storage of data - to design an interface that makes it possible for the data you input to be different from the data it outputs?
I am honestly curious if other databases exhibit this type of behavior. Is there some sort of precedence for this in older RDBMSs? I can't quite wrap my mind around it. My understanding was that although MySql started from humble beginnings, it was sufficiently advanced to see use in many production settings, and was quite popular.
To soothe my nerves, I tried the equivalent operations in Oracle, and to my relief saw
ERROR at line 1:
ORA-01401: inserted value too large for column
I don't use MySql for production use (just for personal tinkering around), and think this has probably scared me off.