[英]What datatype should I use for my column? [MySQL]
I am working on a content management system at work. 我正在工作一个内容管理系统。 I will have a column to hold the body of our users' content (HTML) and I'm not too sure what column type to use.
我将有一个列来保存用户内容(HTML)的正文,但我不太确定要使用哪种列类型。 I don't want to arbitrarily assign a maximum length but I don't know if using a LONGTEXT or BLOB field is overkill.
我不想随意分配最大长度,但是我不知道使用LONGTEXT或BLOB字段是否过大。
Maybe someone could give me a tip or point me in the direction of some sort of "best practices" article for these types of things? 也许有人可以给我一些提示或指导我针对此类事情的“最佳实践”文章的方向? :)
:)
Any help is appreciated 任何帮助表示赞赏
I recommend reading http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html so you know the size constraints of each field. 我建议阅读http://dev.mysql.com/doc/refman/5.0/en/string-type-overview.html,这样您就可以知道每个字段的大小限制。 Afterwards you can choose based off your understanding of the application if you should allow more.
之后,您可以根据自己对应用程序的理解来选择是否允许更多。
Text A TEXT column with a maximum length of 65,535 (216 – 1) characters 文本文本列,最大长度为65,535(216 – 1)个字符
Medium Text A TEXT column with a maximum length of 16,777,215 (224 – 1) characters. 中文本 TEXT列,最大长度为16,777,215(224 – 1)个字符。
Long Text A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 – 1) characters. 长文本(Long Text) TEXT列,最大长度为4,294,967,295或4GB(232 – 1)个字符。
I think you should set some kind of limit. 我认为您应该设置某种限制。 It might be worth looking into what other software does (like Word Press) for example.
例如,可能值得研究其他软件的功能(例如Word Press)。
As for ChaosPandion: GZip is binary, if you're going to do that he should be using BLOB instead. 至于ChaosPandion:GZip是二进制的,如果要这样做,他应该改用BLOB。
使用LONGTEXT,以便您可以搜索它。
您应该GZip和Base64对HTML进行编码,然后将其存储在“文本”列中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.