pgsql 修改表添加表字段方法
增加、修改参数表
do $$
begin
if not exists
(select * from sys_parameters WHERE productid =1 AND programid = 116001 and paramno = 92) then
INSERT INTO sys_parameters ("id", "productid", "programid", "privilege", "paramno", "name", "value", "defvalue", "description", "parentid", "config", "groupname") VALUES (2858, 1, 116001, 0, 92, 押金(保证金), 0, 1, 押金(保证金), NULL, NULL, NULL);
end if;
END $$;
增加表字段
do $$
begin
if not exists
(select * from information_schema.columns where table_name =zaj1 and column_name=eaa01) then
ALTER TABLE zaj1
ADD COLUMN "eaa01" int4;
end if;
END $$;
do $$
begin
if not exists
(select * from sys_mod where code = hzwc and _parentid=416) then
INSERT INTO "public"."sys_mod" ("mod_id", "button_id", "_parentid", "mod_name", "mod_url", "mod_port", "menu_type", "m_state", "code", "icon_cls", "mod_order", "create_time", "update_time", "create_user", "update_user", "language", "hist01") VALUES (2213, NULL, 416, 会诊完成, NULL, NULL, 1, 0, hzwc, icon-serverwarn, 1, NULL, NULL, admin, NULL, zh-CN, 1);
end if;
END $$;
do $$
begin
if not exists
(select * from sys_parameters WHERE productid =1 AND programid = 116001 and paramno = 92) then
INSERT INTO sys_parameters ("id", "productid", "programid", "privilege", "paramno", "name", "value", "defvalue", "description", "parentid", "config", "groupname") VALUES (2858, 1, 116001, 0, 92, 押金(保证金), 0, 1, 押金(保证金), NULL, NULL, NULL);
end if;
END $$;
增加表字段
do $$
begin
if not exists
(select * from information_schema.columns where table_name =zaj1 and column_name=eaa01) then
ALTER TABLE zaj1
ADD COLUMN "eaa01" int4;
end if;
END $$;
do $$
begin
if not exists
(select * from sys_mod where code = hzwc and _parentid=416) then
INSERT INTO "public"."sys_mod" ("mod_id", "button_id", "_parentid", "mod_name", "mod_url", "mod_port", "menu_type", "m_state", "code", "icon_cls", "mod_order", "create_time", "update_time", "create_user", "update_user", "language", "hist01") VALUES (2213, NULL, 416, 会诊完成, NULL, NULL, 1, 0, hzwc, icon-serverwarn, 1, NULL, NULL, admin, NULL, zh-CN, 1);
end if;
END $$;
