PostgreSQL、pgsql为表添加列或判断列存不存在再添加列的方法
程序员文章站
2022-06-28 18:07:39
1.通用方法:
eg:
do $$
begin
begin
alter table dingtalk_corp_info add colum...
1.通用方法:
eg:
do $$ begin begin alter table dingtalk_corp_info add column admin_id text; exception when duplicate_column then raise notice 'column admin_id already exists in dingtalk_corp_info.'; end; end; $$;
2.pgsql 9.6+:
eg:
alter table dingtalk_corp_info add column if not exists admin_id text;
3.直接添加
eg:
alter table dingtalk_corp_info add column admin_id text;
上一篇: 最好喝的咖啡排名?喝咖啡注意事项?
下一篇: fireworks怎么修改字体颜色?