Search code examples
sqloraclecalculated-columnstemp-tables

Add computed column to temporary table Oracle


I want to add a computed column to a global temporary table in Oracle. For the simple tables the request works well.

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

But for the temporary ones it refuses the use of as. Is there a way to add a new computed column to the temporary table in Oracle?


Solution

  • The error message is pretty emphatic. ORA-54010: expression column is not supported for a temporary table.

    the "alter table ma_table add ma_column;" works well when the "as" is there the request is rejected.

    The AS is the necessary bit of syntax for creating virtual columns. But's not the syntax it's the action. The documentation is quite clear on this:

    "You can create virtual columns only in relational heap tables. Virtual columns are not supported for index-organized, external, object, cluster, or temporary tables."

    In this case the limitation of the platform trumps your project requirement.