create or replace function create_view_a() returns void as $$ declare viewExist integer; begin select count(1) into viewExist FROM pg_namespace WHERE nspname = 'basedata'; --判断条件,可自己定义其他条件 if viewExist != 0 then execute 'CREATE VIEW view_a AS SELECT aaa,bbb,ccc FROM basedata.table_a;'; end if; end; $$ language plpgsql; SELECT create_view_a()
标签:满足条件,end,viewExist,create,pg,sql,SELECT,view From: https://www.cnblogs.com/banxia-boke/p/17036754.html