1

我写了这个 PostgreSQL 代码行,但是我遇到了以下错误:

错误:无法连接到服务器“server\sqlexpress”

SQL状态:08001

我究竟做错了什么?

我的代码:

在 Windows 8.1 上使用 PostgreSQL 9.3,在同一窗口上使用 MS SQL Express 2012

  CREATE EXTENSION posgres_fdw;
  Query returned successfully with no result in 11 ms. 

  CREATE SERVER "server\SQLExpress" FOREIGN DATA WRAPPER postgres_fdw 
    OPTIONS (host 'localhost', dbname 'andesmar'); 
  Query returned successfully with no result in 12 ms.

  CREATE USER MAPPING FOR public SERVER "server\sqlexpress" 
    OPTIONS (user 'sa', password '1234'); 
  Query returned successfully with no result in 12 ms.

  CREATE FOREIGN TABLE datosplataforma (
     id                 bigint NOT NULL,
     messagedate        date NOT NULL,
     receiveddate       date NOT NULL,
     latitude           real,
     longitude          real,
     GPSspeed           real,
     bearingangle       integer,
     odometer           integer,
     eventtypeid        integer,
     vehicleid          integer,
     alertid            integer
   )
   SERVER "server\sqlexpress";
   Query returned successfully with no result in 12 ms.

   select * from datosplataforma; 
     ERROR: could not connect to server "server\sqlexpress"
     SQL state: 08001
4

1 回答 1

4

postgres_fdw连接到另一个 PostgreSQL 服务器,而不是 MS SQL Server。

如果要连接到 MS SQL,则需要使用带有 MS SQL ODBC 或 JDBC 驱动程序的 ODBC 或 JDBC FDW,或者使用专用的 MS SQL FDW。

见:http ://wiki.postgresql.org/wiki/Foreign_data_wrappers

于 2014-05-07T02:13:32.260 回答