简体   繁体   English

我应该为列使用哪种数据类型? [MySQL的]

[英]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.

相关问题 我应该使用什么数据类型在MySQL中为我的应用程序存储time()? - What datatype should I use to store time() in MySQL for my application? 我应该在MySQL二进制数据类型列上使用哪个索引 - Which index should I use on binary datatype column mysql 我应该使用哪种数据类型在MySQL上存储较长的加密消息? - What datatype should I use to store long encrypted messages on MySQL? 我的票证表应使用哪种数据类型? - What datatype should I use for my Tickets table? 对于0到3之间的值,我应该使用哪种数据类型 - What datatype should I use for values between 0 to 3 什么应该是mysql表列的数据类型,用于存储注释 - What should be datatype of mysql table column, for storing notes 我应该使用什么日期时间数据类型在MySQL中插入March2016之类的日期? - What date time datatype i should use to insert date like March2016 in mysql? 我应该为Java应用程序的MySql服务器数据库中的Aadhaar卡号使用哪种数据类型? - What datatype should I use for Aadhaar card number in MySql server database for JAVA application? 什么尺寸的INT我应该用于我的自动增量ids MySQL - What size INT should I use for my autoincrement ids MySQL 我应该为 MySQL SQL 数据库中的“2020-04-11T19:54:00.0000000Z”使用什么数据类型? - What datatype should I use for “2020-04-11T19:54:00.0000000Z” in a MySQL SQL database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM