且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在数据库中存储长字符串是否好?

更新时间:2022-04-06 05:30:59

如果你存储一个文件指针,这意味着你需要在每次你想读取字符串时做文件I / O。一些句子不是很长,你可以总是使用长文本数据字段,如果你需要。显然你的数据库会有点大,因为你有文本,但是没关系。这肯定是一个比存储文件更好的选择。

It should be fine to store the string in the database. If you store a file pointer instead, that means you need to do File I/O every time you want to read the string. A few sentences isn't terribly long and you can always use a longtext data field if you need to. Obviously your database will be a little bit larger because you have the text, but that's ok. It is certainly a better alternative than having to store the files.