An attempt to store a string larger than the field (column) size will result in
or
In other words:
should I take care of truncate strings too long before storing them or can I just store them and let the underlying system truncate them for me ?
Side note
I'm talking about data that I don't care if it gets truncated, of course.
It depends on the current SQL_MODE
.
When mode is not strict, your query will produce only a warning, which is normally not visible to you unless requested explicitly. So in effect the string will be silently truncated to the max allowed length.
While in a strict mode, this query will result in a full-featured error and your query will fail
如果没有PHP级别的验证,则字符串将被截断
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.