postgresql中使用dblink

CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator;


CREATE SERVER otherdb FOREIGN DATA WRAPPER postgresql OPTIONS (host 'localhost', dbname 'postgres', port '5432');


CREATE USER MAPPING FOR PUBLIC SERVER otherdb;
drop server otherdb cascade;


SELECT dblink_connect('otherdb','user=postgres password=kobebai');
SELECT *
FROM dblink('otherdb','SELECT generate_series(1,3)')
AS link(col1 integer);


SELECT dblink_exec('otherdb','INSERT INTO tt VALUES'||
' (10,10)', true);

你可能感兴趣的:(postgresql中使用dblink)