Postgres|Postgres Sql新增字段时候判断不存在才新增,存在则不新增

DO $$ BEGIN BEGIN ALTER TABLE recharge_history ADD COLUMN bank_ls VARCHAR(8); EXCEPTION WHEN duplicate_column THEN RAISE NOTICE 'column bank_ls already exists in recharge_history.'; END; END; $$; COMMENT ON COLUMN "public"."recharge_history"."bank_ls" IS '银行流水号';

    推荐阅读