我正在使用 Oracle 10 g。
我有一个需要两列 Long
类型的表:
CREATE TABLE emp
(
id1 LONG NULL,
id2 LONG NULL,
//
// Other columns.
);
当我执行这个查询时,它给了我这个错误:
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.
我在谷歌上搜索,但找不到合适的解决方案。为什么他们不允许两列
LONG
?使用
number
而不是列是个好主意吗?我怎样才能做到这一点?
最佳答案
LONG
列已经很久没有被推荐了;从 8i 开始,我相信。来自 the 11g documentation :
Do not create tables with LONG columns. Use LOB columns (CLOB, NCLOB, BLOB) instead. LONG columns are supported only for backward compatibility.
一个表中只允许有一个
LONG
列。我不完全确定,但我认为这是因为 LONG
数据与其他列一起存储,并且不止一个会使其更难以管理。 LOB 的存储方式不同;参见表 here 进行比较。Oracle 的
LONG
数据类型是“长度不超过 2 GB 的可变字符数据”。如果您要存储数字数据,请使用 NUMBER
。如果您要映射 Java 数据类型(根据您的个人资料猜测!), this table 可能有用。
关于sql - 如何创建具有两个长列的表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11646124/