官术网_书友最值得收藏!

Connecting to SQL Server Spatial

First we need to create a server:

CREATE SERVER fdw_sqlserver_test 
FOREIGN DATA WRAPPER ogr_fdw
OPTIONS (
datasource 'MSSQL:server=CM_DOM\MSSQLSERVER12;database=hgis;UID=postgres_fdw;PWD=postgres_fdw',
format 'MSSQLSpatial');
You may have noticed I have created a postgres_fdw user with the same password.

If you're using Postgre SQL 9.5+, you can use the IMPORT SCHEMA command:

IMPORT FOREIGN SCHEMA "dbo.Wig100_skorowidz" 
FROM SERVER fdw_sqlserver_test INTO data_linked;

Otherwise you will have to specify the table schema explicitly:

CREATE FOREIGN TABLE data_linked.dbo_wig100_skorowidz 
(fid integer ,
geom public.geometry ,
oid integer ,
gid integer ,
version integer ,
godlo character varying ,
nazwa character varying ,
nazwa2 character varying ,
kalibracja character varying ,
pas real ,
slup real )
SERVER fdw_sqlserver_test
OPTIONS (layer 'dbo.Wig100_skorowidz');
By default, PgAdmin does not display foreign tables, so you may have to go to File | Options and tick the Foreign Tables checkbox in the Browser node. In PgAdmin 4, foreign tables seem to be visible by default.

At this stage, you should be able to query the foreign table as if it was local.

主站蜘蛛池模板: 罗源县| 尼勒克县| 梁山县| 西峡县| 珠海市| 石嘴山市| 南和县| 宁陵县| 萨迦县| 仲巴县| 娱乐| 宣城市| 府谷县| 灯塔市| 太湖县| 治多县| 临澧县| 壤塘县| 象州县| 上高县| 二手房| 尚志市| 根河市| 永胜县| 竹溪县| 隆回县| 濮阳市| 新绛县| 洞头县| 吴旗县| 张家界市| 馆陶县| 武威市| 丽江市| 苏尼特左旗| 若尔盖县| 仙游县| 青川县| 祥云县| 怀集县| 嵩明县|