Forum Moderators: coopster

Message Too Old, No Replies

MySQL constraints

         

TheSeoGuy

3:54 pm on Jul 2, 2004 (gmt 0)

10+ Year Member



I am fairly new to MySQL and I can't seem to figure something out.

If I create a column 'product' of type char(4), why does MySQL allow me to do the following:

Insert into tableName (product)
values ('abcdefg');

Then when I look at the results, the data has been truncated to abcd. Am I missing something? It seems like MySQL should tell me that I cannot insert that data because it is beyond the scope of the product columns data type.

Thanks.

coopster

4:22 pm on Jul 2, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, TheSeoGuy!

If you assign a value to a

CHAR
or
VARCHAR
column that exceeds the column's maximum length, the value is truncated to fit.

[dev.mysql.com...]