sql - 如何创建具有两个长列的表?

标签 sql oracle sqldatatypes

我正在使用 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/

相关文章:

mysql - 学说 2 : how to use datatype long?

mysql - 使一些 SQL 行不可见/禁用以改进 SQL 搜索(对于大型数据库)

MySQL 乘法返回错误结果

mysql主键和唯一约束

Oracle - 物化 View 改变结构太慢

sql - SQL Server 中用于存储科学记数法值的正确数据类型? (例如 10^3)

sql - 在 DBMS 中使用桥接实体

sql - Oracle 专有连接 - 在多个条件下加入

小写的 Oracle SQLDeveloper 自动完成(大写怎么样)

sql-server - 为什么我必须设置数据库中每个文本列的最大长度?