我如何创建一个有两个长列的表?

vik*_*iii 3 sql oracle sqldatatypes

我使用的是Oracle 10 g.

我有一个表需要两个Long类型的列:

CREATE TABLE emp
 (
    id1 LONG NULL,
    id2 LONG NULL,
    //
    // Other columns.
);
Run Code Online (Sandbox Code Playgroud)

当我执行此查询时,它给了我这个错误:

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.
Run Code Online (Sandbox Code Playgroud)

我在Google上搜索过,但找不到合适的解决方案.为什么他们不允许两列LONG

使用number而不是列是一个好主意?

我怎样才能做到这一点?

Ale*_*ole 10

LONG很长一段时间没有推荐使用色谱柱; 从8i开始,我相信.从11g文档:

不要创建包含LONG列的表.请改用LOB列(CLOB,NCLOB,BLOB).仅支持LONG列以实现向后兼容性.

您只能LONG在表中使用一列.我不完全确定,但我认为这是因为LONG数据与其他列一起存储,并且不止一个会使它更难以管理.LOB的存储方式不同; 请参阅此处的表格以进行比较.


Oracle的LONG数据类型是"可变长度高达2千兆字节的字符数据".如果您要存储数字数据,请使用NUMBER.

如果您正在映射Java数据类型(从您的配置文件中猜测!),则此表可能有用.

  • @vikiiii - 也许这是一个完整的数据类型不匹配; 你想找到一个匹配像`C``long`这样的数据类型吗?我猜测列名看起来像ID.甲骨文的"LONG"完全不同...... (2认同)