标签:alt func and HERE pgsql fun 字段名 table add
create  or replace function func_add_column() returns int as
$body$
begin
    perform * from pg_tables where tablename = ‘表名‘;
    if found then
        perform * from pg_attribute  where attrelid = ‘表名‘::regclass and attname = ‘字段名‘;
        if not found then
            alter table 表名 add column  字段名 ;
        end if;
             
    end if;
    
   
    return 0 ;
end;
$body$ language plpgsql;
select  func_add_column();
标签:alt func and HERE pgsql fun 字段名 table add
原文地址:https://www.cnblogs.com/19940330a/p/9079339.html