我在postgis中有一个表如下:
CREATE TABLE public.a_meter (
smid integer NOT NULL,
smgeometry public.geometry(Point,32640) NOT NULL,
install_node_code text,
"ID" text,
proj_id text,
voltage_level public.voltage_level_enum2,
design_status public.mv_pole_des,
serial text,
feeder_name text,
specific_id text,
sequence_num smallint,
amp_ratio text,
man_year integer,
ins_year integer,
mspec_no text,
description text,
angle smallint DEFAULT 0,
dist_name public.dist_name_enum,
manufactor text GENERATED ALWAYS AS (public.get_manufactor(mspec_no)) STORED,
spec_name text GENERATED ALWAYS AS (public.a_meter_spec_name(specific_id)) STORED,
type_ad text GENERATED ALWAYS AS (public.a_meter_type_ad(specific_id)) STORED,
maxmtr text GENERATED ALWAYS AS (public.a_meter_maxmtr(specific_id)) STORED,
"Type" text GENERATED ALWAYS AS (public.a_meter_type(specific_id)) STORED,
rat_cur text GENERATED ALWAYS AS (public.a_meter_rat_cur(specific_id)) STORED
);
显而易见,其中有几个生成的列。我使用以下脚本进行备份:
pg_dump.exe --file "C:\\Users\\rasam\\Desktop\\PG_gis.sql" --host "localhost" --port "5432" --username "postgres" --no-password --verbose --format=p --inserts --table "public.a_meter" "electricity"
但是,生成的备份不是有效的 SQL 代码,因为生成的列未正确备份。这些值像常规列一样存储,如下所示:
INSERT INTO public.a_meter VALUES (204, '0101000020807F00008FC2F528A22A204115AE47A1FFA14F41', '', 'AMP3153546', '', '', 'اجرا شده', '', 'نادر - PDS3570966 - 8', '7', NULL, '', NULL, NULL, '22', '', 180, 'بجنورد', 'BEW', 'AMP017', 'آنالوگ', 'ندارد', 'BE-96', '');
奇怪的是,当我克隆表模式并用数据填充它时,备份会正确生成。但是,我无法为所有客户的所有桌子都这样做。