- Mastering PostGIS
- Dominik Mikiewicz Michal Mackiewicz Tomasz Nycz
- 173字
- 2021-07-02 22:52:23
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.
推薦閱讀
- Microsoft Dynamics CRM Customization Essentials
- 樂高機器人EV3設計指南:創造者的搭建邏輯
- TestStand工業自動化測試管理(典藏版)
- Zabbix Network Monitoring(Second Edition)
- Multimedia Programming with Pure Data
- 西門子S7-200 SMART PLC實例指導學與用
- 工業控制系統測試與評價技術
- SAP Business Intelligence Quick Start Guide
- 智能生產線的重構方法
- 網絡安全技術及應用
- 計算機組網技術
- 嵌入式Linux系統實用開發
- 寒江獨釣:Windows內核安全編程
- MongoDB 4 Quick Start Guide
- 機器人剛柔耦合動力學