Storing messages as BLOB (Binary Large Object) or ordinary text?

守給你的承諾、 提交于 2019-12-12 16:21:38

问题


What is the best way to store messaging texts in large/big web sites: BLOB or ordinary text in table or something else? Database: MySQL.


回答1:


There are a lot of questions you need to ask yourself when making that decision. There's a very detailed article, To BLOB or not to BLOB, that is the question: Whether to store string in BLOB, or CHAR, or VARCHAR?, that talks about some of the things to consider.




回答2:


If by "messages" you mean something like SMS or IRC, stuff with a defined limit then I think VARCHAR is the most appropriate. If your messages can really be any size then TEXT would be better.

But I wouldn't have thought BLOB was suitable for anything except perhaps attachments (assuming your system has them). BLOBs are meant for binary files (e.g. images, Word documents) not pure text.



来源:https://stackoverflow.com/questions/2208078/storing-messages-as-blob-binary-large-object-or-ordinary-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!