数据仓库服务 GAUSSDB(DWS)-GAUSS-00551 -- GAUSS-00560:GAUSS-00556: "cannot change data type of view column '%s' from %s to %s"
数据仓库服务 GAUSSDB(DWS)-GAUSS-00551 -- GAUSS-00560:GAUSS-00556: "cannot change data type of view column '%s' from %s to %s"
GAUSS-00556: "cannot change data type of view column '%s' from %s to %s"
SQLSTATE: 42P16
错误原因:使用CREATE OR REPLACE VIEW创建视图时,如果该同名视图已存在,那么新的视图定义必须返回和原视图相同的列(即具有相同的列名顺序和数据类型),但是允许增加额外的列,否则会出现报错。
解决办法:保证新视图和现有视图中列的数据类型一致。
例如:CREATE OR REPLACE VIEW方式修改列类型时报错:
CREATE OR REPLACE VIEW view1 as select * from tbl2; ERROR: cannot change data type of view column "b" from integer to text
可通过CREATE OR REPLACE VIEW的方式增加列:
CREATE OR REPLACE VIEW myview as select tbl1.*,tbl2.b as c from tbl1 ,tbl2 where tbl1.a = tbl2.a; CREATE VIEW