इससे भी आसान तरीका है:
db_B से कनेक्ट करें और निम्नलिखित को निष्पादित करें:
CREATE OR REPLACE FUNCTION dblink(text, text)
RETURNS SETOF record AS
'$libdir/dblink', 'dblink_record'
LANGUAGE 'c' VOLATILE STRICT
COST 1
ROWS 1000;
ALTER FUNCTION dblink(text, text) OWNER TO postgres;
GRANT EXECUTE ON FUNCTION dblink(text, text) TO public; -- or whatever
INSERT INTO tbl_B select * from
(SELECT * from dblink('hostaddr=localhost port=5432 dbname=db_A user=postgres password=postgres',
'select id, a, b from tbl_A limit 20 '
)
t(
id integer,
a integer,
b integer
)) as q;