这与我在Getting Error while creating a view in oracle DB
的问题有关我尝试了以下内容,但在第6行获取重复的错误列
CREATE VIEW ReturnCode90
AS
SELECT t.ret_code,
TO_CHAR (t.creation_dt, 'DD-MON-YYYY HH24:MI:SS') Created_Date,
CURRENT_TIMESTAMP Curr_tmp,
t.*
FROM buff.log t
WHERE t.ret_Code = '90'
order by t.creation_dt desc;
答案 0 :(得分:5)
您正在创建一个具有相同列ret_code
两次的视图;如果您在视图中两次出现相同的列,则需要为两次出现之一使用别名:
CREATE VIEW ReturnCode90
AS
SELECT t.ret_code as someAlias,
TO_CHAR (t.imx_creation_dt, 'DD-MON-YYYY HH24:MI:SS') Created_Date,
CURRENT_TIMESTAMP Curr_tmp,
t.*
FROM imxbuff.bank_imx_pmt_head t
WHERE t.ret_Code = '90'
order by t.imx_creation_dt desc;
如果您不想这样做,可以从选择列表中删除该列
SELECT TO_CHAR (t.imx_creation_dt, 'DD-MON-YYYY HH24:MI:SS') Created_Date,
CURRENT_TIMESTAMP Curr_tmp,
t.*
或者,更好的是,明确地编写列名而不是使用*
:
SELECT t.ret_code,
TO_CHAR (t.imx_creation_dt, 'DD-MON-YYYY HH24:MI:SS') Created_Date,
CURRENT_TIMESTAMP Curr_tmp,
t.otherColumn1,
t.otherColumn2,
...