dblink 多数据库数据操作
当前数据库为Temp;
希望从数据库qohdb查询数据,导入表groups中。
INSERT INTO groups
SELECT * FROM
dblink('host=127.0.0.1 user=sfuser password=kaisenmaru dbname=qohdb'::text, 'select * from groups'::text)
AS t1(groupid bigint, groupname group_name);
CREATE VIEW qohdbClient AS
SELECT groupid, clientid from
dblink('host=127.0.0.1 user=sfuser password=kaisenmaru dbname=qohdb'::text, 'select groupid, clientid from clients'::text)
AS t2(groupid bigint, clientid bigint);
UPDATE clients SET groupid = qohdbClient.groupid
from qohdbClient
where clients.clientid=qohdbClient.clientid;
DROP VIEW qohdbClient;