开发者

Not able to store large string in db in RoR 3

I'm only allow to store around 250 characters i开发者_JAVA百科n db column. When I try to add large string it automatically omit the extra character. The type I used in scaffold is string. How can I store large strings in db. I'm using MySQL as db.


use data type "text" instead of "string"

CHAR( ) : A fixed section from 0 to 255 characters long.

VARCHAR( ): A variable section from 0 to 255 characters long.

TINYTEXT: A string with a maximum length of 255 characters.

TEXT: A string with a maximum length of 65535 characters.

BLOB: A string with a maximum length of 65535 characters.

MEDIUMTEXT: A string with a maximum length of 16777215 characters.

MEDIUMBLOB: A string with a maximum length of 16777215 characters.

LONGTEXT: A string with a maximum length of 4294967295 characters.

LONGBLOB: A string with a maximum length of 4294967295 characters.


Instead of using :string as your column type, use :text - it will give you much more space to store your string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜