Oracle 的 'GENERATED ALWAYS' 语法在 Vertica 中是否等效?

Oracle's 'GENERATED ALWAYS' syntax equivalent in Vertica?

对于这个问题没有太多背景知识,我深表歉意,但我的任务是将我们的一些 Oracle 查询转换为 Vertica 语法,我在理解有关 GENERATED ALWAYS Oracle 命令的文档时遇到了困难它与案例陈述有关。

根据我的发现,Oracle 中的 GENERATED ALWAYS 似乎等于 Vertica 中的 AUTO INCREMENT

这是我需要在 Vertica 中重写的案例语句示例。乍一看,它似乎只是在告诉它使用别名,但我不确定我是否理解正确。

FIELD_NAME varchar2(25) GENERATED ALWAYS as(
      case "FIELD_NAME"
        when 'ABC'
        then 'ABC / Category_ABC'
        when 'DEF'
        then 'DEF / Category_DEF'
        else 'Other'
      end)

这本质上是一样的吗?简单地删除 GENERATED ALWAYS 块是否安全?还是这里发生了更大的事情?

FIELD_NAME varchar2(25) as(
      case "FIELD_NAME"
        when 'ABC'
        then 'ABC / Category_ABC'
        when 'DEF'
        then 'DEF / Category_DEF'
        else 'Other'
      end)

这绝不是查询、上下文、phenderbender。这是一个数据定义上下文。 GENERATED ALWAYS 或 GENERATED BY DEFAULT 是您在创建 table 或更改 table 以创建或修改列时定义的列属性。

Vertica 的语法是列定义的 DEFAULT 子句。

如果我在此处查看 Oracle 文档:

https://oracle-base.com/articles/11g/virtual-columns-11gr1

我会像这样在 Vertica 中编写他们的示例:

CREATE TABLE employees (
  id          INTEGER,
  first_name  VARCHAR(10),
  last_name   VARCHAR(10),
  salary      NUMERIC(9,2),
  comm1       NUMERIC(3),
  comm2       NUMERIC(3),
  salary1     NUMERIC(9,2) DEFAULT (ROUND(salary*(1+comm1/100),2)),
  salary2     NUMERIC(9,2) DEFAULT (ROUND(salary*(1+comm2/100),2)),
  CONSTRAINT employees_pk PRIMARY KEY (id)
);

INSERT INTO employees (id, first_name, last_name, salary, comm1, comm2)
VALUES (1, 'JOHN', 'DOE', 100, 5, 10);

INSERT INTO employees (id, first_name, last_name, salary, comm1, comm2)
VALUES (2, 'JAYNE', 'DOE', 200, 10, 20);
COMMIT;

SELECT * FROM employees;
-- out  id | first_name | last_name | salary | comm1 | comm2 | salary1 | salary2 
-- out ----+------------+-----------+--------+-------+-------+---------+---------
-- out   1 | JOHN       | DOE       | 100.00 |     5 |    10 |  105.00 |  110.00
-- out   2 | JAYNE      | DOE       | 200.00 |    10 |    20 |  220.00 |  240.00
-- out (2 rows)
-- out 
-- out Time: First fetch (2 rows): 182.567 ms. All rows formatted: 182.674 ms