0

嗨,我正在通过以下方式创建视图

CREATE OR REPLACE FORCE VIEW tableA (field1, field2)
AS
  SELECT 
    CAST("state" AS        CHAR(2)),
    CAST("LOCALITY_NAME" AS   CHAR(31)),
  FROM tableB;

我需要再添加一个名为“id”的列,并为所有行填充硬编码值“abc”。在创建视图时可以这样做吗?我看过这个帖子,但我无法理解它如何适合我的情况。

4

2 回答 2

2
SELECT 'abc' as id,
        CAST("state" AS CHAR(2)),
        CAST(LOCALITY_NAME AS CHAR(31)),
FROM tableB
于 2013-07-10T18:08:40.487 回答
0

Sure, just add it as a constanct value:

CREATE OR REPLACE FORCE VIEW tableA (field1, field2)
AS
  SELECT
    CAST("state" AS        CHAR(2)),
    CAST("LOCALITY_NAME" AS   CHAR(31)),
    'abc' AS id 
  FROM tableB;
于 2013-07-10T18:11:40.997 回答