1 2 3 4 5 6 7 8 9 10 11 12 13 14
| # 设置连接 --- 本地可以简写,不需要hostaddr,port,user,password select dblink_connect('localconn','dbname=gpdb'); --- 远程必须写全 select dblink_connect('disconn','hostaddr=192.168.157.128 port=5432 dbname=gpdb user=gpadmin password=123456');
# 执行查询操作 select * from dblink('localconn','select * from public.demo') as a(a int,b text); select * from dblink('dbname=gpdb','select * from public.demo') as a(a int,b text); insert into public.demo_load select * from dblink('dbname=gpdb','select * from public.demo') as a(a int,b text); insert into public.demo_load select * from dblink('hostaddr=192.168.157.128 port=5432 dbname=gpdb user=gpadmin password=123456','select * from public.demo') as a(a int,b text);
# 注意 使用insert * from select时不能只使用dblink_connect设置好的连接,需要数据库连接串
|