mysql中的字符串长度是否有限制? [英] Are there any limits on length of string in mysql?

查看:439
本文介绍了mysql中的字符串长度是否有限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rails中使用MySQL数据库.我创建了一个string类型的字段.它的长度有限制吗? text类型如何?
同样,由于text是可变大小的,我相信使用文本对象会带来额外的成本.如果有的话,他们能变得有多重要?

I am using MySQL data base with Rails. I have created a field of type string. Are there any limits to its length? What about type text?
Also as text is variable sized, I believe there would be extra costs associated with using text objects. How important can they get, if at all?

推荐答案

通常,字符串应用于短文本.例如,它是MySQL下的VARCHAR(255).

String, in general, should be used for short text. For example, it is a VARCHAR(255) under MySQL.

文本使用数据库中较大的文本,例如在MySQL中,类型为TEXT.

Text uses the larger text from the database, like, in MySQL, the type TEXT.

有关此工作方式以及MySQL内部和限制等信息,请参阅Pekka的其他答案.

For information on how this works and the internals in MySQL and limits and such, see the other answer by Pekka.

例如,如果您要一段,我将使用文本.如果您要输入用户名或电子邮件,请使用字符串.

If you are requesting, say, a paragraph, I would use text. If you are requesting a username or email, use string.

这篇关于mysql中的字符串长度是否有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆