Skip to content

Nova base issue 40

Peter edited this page Jan 1, 2022 · 5 revisions

Montando as estruturas FDW de clonagem

Usar o make target build_fdwtable. Por exemplo para que a tabela original optim.jurisdiction da base dl03t_main tenha mapeado o seu FDW optim.jurisdiction22 em outra base qualquer do mesmo servidor, é preciso rodar esse make e copiar o resultado na base destino. Por exemplo:

make build_fdwtable fdwOrigBase=dl03t_main fdwOrigSchema=optim fdwOrigName=jurisdiction fdwName=optim.jurisdiction22

resulta no script:

DROP FOREIGN TABLE IF EXISTS optim.jurisdiction22;
CREATE FOREIGN TABLE optim.jurisdiction22 (
 osm_id bigint,
 jurisd_base_id integer,
 jurisd_local_id integer,
 name text,
 parent_abbrev text,
 abbrev text,
 wikidata_id bigint,
 lexlabel text,
 isolabel_ext text,
 ddd integer,
 info jsonb,
 admin_level integer,
 parent_id bigint,
 name_en text,
 isolevel integer  -- so precisou remover a virgula aqui.
) SERVER foreign_server
  OPTIONS (schema_name 'optim', table_name 'jurisdiction');

Por função SQL:

SELECT column_name,  data_type
  FROM information_schema.columns
 WHERE table_schema = 'optim'
   AND table_name   = 'jurisdiction'
   AND table_catalog = 'dl03t_main'
     ORDER BY ordinal_position;