为什么 Oracle 不识别存储的生成列定义?
Why doesn't Oracle recognize a stored generated column definition?
我在 CREATE TABLE
语句中定义了以下生成的列:
NET_ROWS_ADDED NUMBER(18) GENERATED ALWAYS AS (ROW_COUNT - PREV_ROW_COUNT) /*STORED*/,
ROW_COUNT
和 PREV_ROW_COUNT
是以前在同一 table.
中定义的简单 NUMBER(18)
列
一切正常,如其所写。
但是如果我取消注释 STORED
选项,我会得到:
ORA-00907: missing right parenthesis
我需要将其转换为 STORED
生成的列。
这里的语法有什么问题?在我看来一切都是正确的...
Oracle 不在磁盘上存储虚拟列,它只是按需求值。您可能对 MySQL 中的 STORED 选项感到困惑。由于 Oracle 中没有 STORED
子句,因此会引发语法错误。
GENERATED ALWAYS
The optional keywords GENERATED ALWAYS are provided for semantic
clarity. They indicate that the column is not stored on disk, but is
evaluated on demand.
VIRTUAL
The optional keyword VIRTUAL is provided for semantic
clarity.
我在 CREATE TABLE
语句中定义了以下生成的列:
NET_ROWS_ADDED NUMBER(18) GENERATED ALWAYS AS (ROW_COUNT - PREV_ROW_COUNT) /*STORED*/,
ROW_COUNT
和 PREV_ROW_COUNT
是以前在同一 table.
NUMBER(18)
列
一切正常,如其所写。
但是如果我取消注释 STORED
选项,我会得到:
ORA-00907: missing right parenthesis
我需要将其转换为 STORED
生成的列。
这里的语法有什么问题?在我看来一切都是正确的...
Oracle 不在磁盘上存储虚拟列,它只是按需求值。您可能对 MySQL 中的 STORED 选项感到困惑。由于 Oracle 中没有 STORED
子句,因此会引发语法错误。
GENERATED ALWAYS
The optional keywords GENERATED ALWAYS are provided for semantic clarity. They indicate that the column is not stored on disk, but is evaluated on demand.
VIRTUAL
The optional keyword VIRTUAL is provided for semantic clarity.