oracle 如何创建具有两个长列的表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11646124/
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
How I can create a table having two long columns?
提问by vikiiii
I am using Oracle 10 g.
我正在使用 Oracle 10 g。
I have a table which needs two columns of the Long
type:
我有一个需要两列Long
类型的表:
CREATE TABLE emp
(
id1 LONG NULL,
id2 LONG NULL,
//
// Other columns.
);
When I am executing this query, it is giving me this error:
当我执行这个查询时,它给了我这个错误:
Error report:
SQL Error: ORA-01754: a table may contain only one column of type LONG
01754. 00000 - "a table may contain only one column of type LONG"
*Cause: An attempt was made to add a LONG column to a table which already
had a LONG column. Note that even if the LONG column currently
in the table has already been marked unused, another LONG column
may not be added until the unused columns are dropped.
*Action: Remove the LONG column currently in the table by using the ALTER
TABLE command.
I searched on Google, but I could not find a proper solution. Why do they not allow two columns of LONG
?
我在谷歌上搜索,但找不到合适的解决方案。为什么他们不允许两列LONG
?
Is using number
instead of a column a good idea?
使用number
而不是列是个好主意吗?
How can I achieve this?
我怎样才能做到这一点?
回答by Alex Poole
LONG
columns have not been recommended for a long time; since 8i, I believe. From the 11g documentation:
LONG
很久没有推荐的栏目了;从 8i 开始,我相信。从11g 文档:
Do not create tables with LONG columns. Use LOB columns (CLOB, NCLOB, BLOB) instead. LONG columns are supported only for backward compatibility.
不要创建带有 LONG 列的表。请改用 LOB 列(CLOB、NCLOB、BLOB)。支持 LONG 列只是为了向后兼容。
You were only ever allowed one LONG
column in a table. I'm not entirely sure, but I think that was because the LONG
data was stored alongside the other columns, and more than one would make it even more unmanageable. LOBs are stored differently; see the table herefor a comparison.
LONG
一个表中只允许有一列。我不完全确定,但我认为这是因为LONG
数据与其他列一起存储,并且不止一个会使其更难以管理。LOB 的存储方式不同;请参阅此处的表格进行比较。
Oracle's LONG
datatype is 'Character data of variable length up to 2 gigabytes'. If you're storing numeric data, use NUMBER
.
Oracle 的LONG
数据类型是“最多 2 GB 的可变长度字符数据”。如果您要存储数字数据,请使用NUMBER
.
If you're mapping Java data types (guessing from your profile!), this tablemay be of use.
如果您要映射 Java 数据类型(根据您的个人资料猜测!),此表可能有用。
回答by Yaroslav
Since Oracle 8i the LONG datatype is advised not to be used and instead use CLOB or NLOB datatypes.
从 Oracle 8i 开始,建议不要使用 LONG 数据类型,而是使用 CLOB 或 NLOB 数据类型。
Just in case check Oracle 10g documentationabout datatypes. Also check here for other details
以防万一,请查看有关数据类型的Oracle 10g 文档。另请在此处查看其他详细信息