【问题标题】:Add computed column to temporary table Oracle将计算列添加到临时表 Oracle
【发布时间】:2017-09-23 13:53:01
【问题描述】:

我想在 Oracle 的全局临时表中添加一个计算列。 对于简单表,该请求运行良好。

alter table ma_table add ma_column as (column1*column2);

但对于临时的,它拒绝使用as。 有没有办法在 Oracle 的临时表中添加一个新的计算列?

【问题讨论】:

  • 错误信息非常明确。 ORA-54010: expression column is not supported for a temporary table。为什么要这样做?
  • 是项目约束,其实是“alter table ma_table add ma_column;”当“as”存在时,请求被拒绝时效果很好。

标签: sql oracle calculated-columns temp-tables


【解决方案1】:

我刚刚找到了方法, 我添加了更改请求的列

alter table ma_table add ma_column [type];

然后创建一个在执行插入请求时执行更新请求的脚本

update ma_table set ma_column=(colonne1*colonne2);

【讨论】:

    【解决方案2】:

    错误信息非常强调。 ORA-54010: expression column is not supported for a temporary table.

    "alter table ma_table add ma_column;"当“as”存在时,请求被拒绝时效果很好。

    AS 是创建虚拟列的必要语法。但不是语法而是动作。这个documentation is quite clear

    “您只能在关系堆表中创建虚拟列。索引组织、外部、对象、集群或临时表不支持虚拟列。”

    在这种情况下,平台的限制胜过您的项目要求。

    【讨论】:

    • 好的,谢谢,我找到了一种方法,我必须创建一个脚本,为每个插入请求执行更新请求。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2023-03-13
    • 2014-02-14
    • 2012-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    • 1970-01-01
    相关资源
    最近更新 更多