文本文件的 Oracle 数据类型?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4495759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle Data Type for text file?
提问by TERACytE
I need to create a table in Oracle that will store a series of large text files. After looking at the Oracle datatype's it is unclear what type I should use to store the files.
我需要在 Oracle 中创建一个表来存储一系列大型文本文件。在查看了 Oracle 数据类型之后,我不清楚应该使用什么类型来存储文件。
The limits on the text specific types like VARCHAR2 seem very small (32K). The other types don't seem to be the right match for a text file (e.g. BFILE).
像 VARCHAR2 这样的文本特定类型的限制似乎非常小 (32K)。其他类型似乎不适合文本文件(例如 BFILE)。
Does anyone have an opinion on the right type to use?
有没有人对使用正确的类型有意见?
回答by Gary Myers
The difference between CLOB and BLOB/BFILE is that CLOBs are treated as Text. That is, if you pull a CLOB from the database it will do any conversion necessary from the database character set to the client character set (eg removing an accent from an ê). Similarly, when a CLOB is created by a client, there can be a conversion from the client character set to the database character set. If both client and database character sets are the same, then no conversion is needed or performed.
CLOB 和 BLOB/BFILE 之间的区别在于 CLOB 被视为文本。也就是说,如果您从数据库中提取 CLOB,它将执行从数据库字符集到客户端字符集的任何必要转换(例如,从 ê 中删除重音符号)。类似地,当客户端创建 CLOB 时,可能会发生从客户端字符集到数据库字符集的转换。如果客户端和数据库字符集相同,则不需要或不执行任何转换。
NCLOB is like CLOB except that rather than the database character set, the conversion uses the NLS NCHAR characterset.
NCLOB 与 CLOB 类似,不同之处在于转换使用 NLS NCHAR 字符集而不是数据库字符集。
A BLOB/BFILE will not be subject to the conversion rules.
BLOB/BFILE 不受转换规则的约束。
So GENERALLY I would use a CLOB for text, but if there is some checksum/audit trail logic where I don't want even the slightest possibility of a character set conversion, I might opt for a BLOB/BFILE. I wouldn't consider a LONG or LONG RAW.
所以一般我会使用 CLOB 来处理文本,但如果有一些校验和/审计跟踪逻辑,我不希望字符集转换的可能性很小,我可能会选择 BLOB/BFILE。我不会考虑 LONG 或 LONG RAW。
回答by Matthew Watson
Depends on what version of Oracle you are using Either CLOB or Long
取决于您使用的是哪个版本的 Oracle CLOB 或 Long
回答by gmhk
The LOB datatypes for character data are CLOB and NCLOB. They can store up to 8 terabytes of character data (CLOB) or national character set data (NCLOB).
字符数据的 LOB 数据类型是 CLOB 和 NCLOB。它们可以存储多达 8 TB 的字符数据 (CLOB) 或国家字符集数据 (NCLOB)。
Later Oracle recommends that you convert existing LONG RAW columns to LOB columns. LOB columns are subject to far fewer restrictions than LONG columns. Further, LOB functionality is enhanced in every release, whereas LONG RAW functionality has been static for several releases.
后来 Oracle 建议您将现有的 LONG RAW 列转换为 LOB 列。LOB 列受到的限制比 LONG 列少得多。此外,LOB 功能在每个版本中都得到了增强,而 LONG RAW 功能在几个版本中一直是静态的。