<![CDATA[Snooda]]> http://www.trreps.com/index zh-cn http://www.trreps.com/read/340 <![CDATA[mysql的varchar和char长度的含义(中文长度Q]]> snooda <admin@snooda.com> Mon, 07 Dec 2015 11:22:14 +0000 http://www.trreps.com/read/340

    可以通过mysql官方文档来看Q?br/>    http://dev.mysql.com/doc/refman/5.0/en/char.html
    

The CHAR and VARCHAR types are declared with a length that indicates the maximum number of characters you want to store. For example, CHAR(30) can hold up to 30 characters.

    x持的?0个字W(charactersQ,而不?0字节QbytesQ?br/>
    l测试,l果也是W合文档的。varchar(30)可以存储30个汉?br/>

    附加问题Q如果传入了出长度的内容,会有什么结果?br/>
If strict SQL mode is not enabled and you assign a value to a CHAR or VARCHAR column that exceeds the column's maximum length, the value is truncated to fit and a warning is generated.

     文档中提到。默认情况下会截断而不q回错误。如果需要返回错误,需要开启strict mode











Tags - , ]]>
һaƬ_һػƴƬ_ձһػƴƬ <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <ı> <ı> <ı> <ı> <ı> <ı>