CREATE TABLE `MYTAB` (`No` INT (3) UNSIGNED DEFAULT '0',
`Name` VARCHAR (3)) TYPE = InnoDB;
Now When I am trying to insert records into this table having "name" column's length greater than 3 It is truncating the string to three chars and inserting into the table.
for example : insert into MYTAB values(1,'ABCDEF')
is inserting a record into table MYTAB and now MYTAB contains
mysql> select * from MYTAB;
| No | Name |
| 1 | ABC |
1 row in set (0.00 sec)
Instead this while entering the data into this table itself I expected mysql should throw exception saying that the length of name column is exceeding. Now I would like to force mysql to throw this exception. Please help me is there any way to force mysql to raise such exceptions.
Since MySQL still does not support transactions on all tables (MyISAM) they have to ignore most errors that would cause a rollback in other DBMS'. As such, you can insert character data into an int column, you can exceed the length of a CHAR (or INT for that matter) and it will not die. As far as I know this is intended functionality and is not slated to change.