问题描述
我们在Oracle 11g中有一个带有varchar2列的表.我们使用专有的编程语言,其中此列定义为字符串.我们最多可以在此列中存储2000个字符(4000个字节).现在的要求是该列需要存储2000个以上的字符(实际上是无限个字符).由于维护原因,DBA不喜欢BLOB或LONG数据类型.
We have a table in Oracle 11g with a varchar2 column. We use a proprietary programming language where this column is defined as string. Maximum we can store 2000 characters (4000 bytes) in this column. Now the requirement is such that the column needs to store more than 2000 characters (in fact unlimited characters). The DBAs don't like BLOB or LONG datatypes for maintenance reasons.
我能想到的解决方案是从原始表中删除此列,并为此列创建一个单独的表,然后将每个字符存储在一行中,以获取无限个字符.该表将与原始表一起进行查询.
The solution that I can think of is to remove this column from the original table and have a separate table for this column and then store each character in a row, in order to get unlimited characters. This tble will be joined with the original table for queries.
有没有更好的解决方案来解决这个问题?
Is there any better solution to this problem?
更新:专有的编程语言允许定义string和blob类型的变量,没有CLOB选项.我理解所给出的响应,但是不能承担DBA的责任.我知道,背离BLOB或LONG将是开发人员的噩梦,但仍然无济于事.
UPDATE: The proprietary programming language allows to define variables of type string and blob, there is no option of CLOB. I understand the responses given, but I cannot take on the DBAs. I understand that deviating from BLOB or LONG will be developers' nightmare, but still cannot help it.
更新2:如果我最多需要8000个字符,我可以再增加3列,这样我将有4个列,每个列有2000个字符,以获得8000个字符.因此,当第一列已满时,值将溢出到下一列,依此类推.这种设计会有不良的副作用吗?请提出建议.
UPDATE 2: If maximum I need is 8000 characters, can I just add 3 more columns so that I will have 4 columns with 2000 char each to get 8000 chars. So when the first column is full, values would be spilled over to the next column and so on. Will this design have any bad side effects? Please suggest.
推荐答案
如果需要blob,请说服dba,这就是您所需要的.这些数据类型是有原因的,任何滚动实现都会比内置类型差.
If a blob is what you need convince your dba it's what you need. Those data types are there for a reason and any roll your own implementation will be worse than the built in type.
另外,您可能希望查看 CLOB 类型,因为它可以满足您的需求很好.
Also you might want to look at the CLOB type as it will meet your needs quite well.
这篇关于如何在Oracle 11g中存储无限字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!