Oracle 中 long 和 long 原始数据类型有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12722636/
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
what is the difference between long and long raw data types in Oracle?
提问by Rajkumar
My understanding is Long data type can store the actual string(chars), while Long raw data type stores the binary values of the string(chars). Is it right? Can a table have only one long type column?
我的理解是 Long 数据类型可以存储实际的字符串(字符),而 Long 原始数据类型存储字符串(字符)的二进制值。这样对吗?一张表可以只有一个长类型的列吗?
回答by Alex Poole
The data types are described in the documentation; LONG
is explained here(or the 11gR2 version):
数据类型在文档中描述;LONG
在这里解释(或11gR2 版本):
LONG columns store variable-length character strings containing up to 2 gigabytes -1, or 231-1 bytes. LONG columns have many of the characteristics of VARCHAR2 columns. You can use LONG columns to store long text strings.
LONG 列存储最多包含 2 GB -1 或 231-1 字节的可变长度字符串。LONG 列具有 VARCHAR2 列的许多特征。您可以使用 LONG 列来存储长文本字符串。
And LONG RAW
is here:
The RAW and LONG RAW datatypes store data that is not to be interpreted (that is, not explicitly converted when moving data between different systems) by Oracle Database. These datatypes are intended for binary data or byte strings. For example, you can use LONG RAW to store graphics, sound, documents, or arrays of binary data, for which the interpretation is dependent on the use.
RAW 和 LONG RAW 数据类型存储的数据不会被 Oracle 数据库解释(即,在不同系统之间移动数据时不会显式转换)。这些数据类型用于二进制数据或字节字符串。例如,您可以使用 LONG RAW 来存储图形、声音、文档或二进制数据数组,其解释取决于使用情况。
So a RAW
or LONG RAW
can contain the binary representation of characters, but won't be subject to character set conversion etc. so probably isn't all that useful for that; an can contain any other binary data - anything that isn't supposed to represent text.
所以 a RAW
orLONG RAW
可以包含字符的二进制表示,但不会受到字符集转换等的影响,所以可能不是那么有用;an 可以包含任何其他二进制数据 - 任何不应该代表文本的东西。
From the same LONG
section:
来自同LONG
一部分:
A table can contain only one LONG column.
一张表只能包含一个 LONG 列。
However, LONG
is deprecated in favour of LOB
(CLOB
or NCLOB
for text, BLOB
for everything else), so you shouldn't be using them for new work, and should at least be considering replacing any you already have. Again from that same section on LONG
:
但是,LONG
不推荐使用LOB
(CLOB
或NCLOB
用于文本,BLOB
用于其他所有内容),因此您不应该将它们用于新工作,并且至少应该考虑替换您已经拥有的任何内容。再次从同一部分LONG
:
Do not create tables with LONG columns. Use LOB columns (CLOB, NCLOB, BLOB) instead. LONG columns are supported only for backward compatibility.
Oracle also recommends that you convert existing LONG columns to LOB columns.
不要创建带有 LONG 列的表。请改用 LOB 列(CLOB、NCLOB、BLOB)。支持 LONG 列只是为了向后兼容。
Oracle 还建议您将现有的 LONG 列转换为 LOB 列。
This documentation on migrating from LONG
to LOB
might be of interest.
这个关于从LONG
to迁移的文档LOB
可能会引起人们的兴趣。