- 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.
推薦閱讀
- Hands-On Deep Learning with Apache Spark
- Windows XP中文版應(yīng)用基礎(chǔ)
- STM32G4入門(mén)與電機(jī)控制實(shí)戰(zhàn):基于X-CUBE-MCSDK的無(wú)刷直流電機(jī)與永磁同步電機(jī)控制實(shí)現(xiàn)
- 工業(yè)機(jī)器人現(xiàn)場(chǎng)編程(FANUC)
- VB語(yǔ)言程序設(shè)計(jì)
- 突破,Objective-C開(kāi)發(fā)速學(xué)手冊(cè)
- 激光選區(qū)熔化3D打印技術(shù)
- 青少年VEX IQ機(jī)器人實(shí)訓(xùn)課程(初級(jí))
- Linux Shell Scripting Cookbook(Third Edition)
- Drupal高手建站技術(shù)手冊(cè)
- 計(jì)算機(jī)辦公應(yīng)用培訓(xùn)教程
- 教育創(chuàng)新與創(chuàng)新人才:信息技術(shù)人才培養(yǎng)改革之路(四)
- 商務(wù)智能
- Hadoop大數(shù)據(jù)開(kāi)發(fā)基礎(chǔ)
- Cassandra Design Patterns