在数据库中存储长字符串是否好? [英] Is it good to store long strings in a database?

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

问题描述

我需要在数据库中存储长字符串。该字符串可以是5或6个句子长。你认为这是一个好的设计策略。或者应该存储该字符串的标识,然后与包含存储字符串的文件的位置的另一个表创建关系。
你可以给出两者的优点和缺点。

I need to store long strings in a database. the string may be 5 or 6 sentences long. do you think this is a good design strategy. or should I store an id for that string and then create a relationship with another table that contains the location of the file storing the string. could you please give advantages and disadvantages of both.

字符串已经预处理并存储在数据库中。任何修改将读取整个字符串并完全替换它。所以你可以假定字符串是不可分割的。

the strings have been preprocessed and stored in the database. any modification would read the entire string and replace it completely. so you can assume that the string is indivisible.

推荐答案

如果你存储一个文件指针,这意味着你需要在每次你想读取字符串时做文件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.

这篇关于在数据库中存储长字符串是否好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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