CREATE SERVER

Name

CREATE SERVER -- 定义一个新的外服务器

Synopsis

CREATE SERVER server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ]
    FOREIGN DATA WRAPPER fdw_name
    [ OPTIONS ( option 'value' [, ... ] ) ]

描述

CREATE SERVER定义一个新的外服务器。定义该服务器的用户将成为其所有者。

一个外服务器通常封装一个外数据封装器用于访问一个外部数据资源的连接信息。 额外的特定用户连接信息可以通过用户映射来声明。

服务器名称必须是数据库内独一无二的。

创建一个服务器需要使用的外部数据封装包上的USAGE权限。

参数

server_name

要创建的外部服务器的名称。

server_type

可选的服务器类型。

server_version

可选的服务器类型。

fdw_name

管理服务器的外部数据封装包的名称。

OPTIONS ( option 'value' [, ... ] )

该子句为服务器声明选项。选项通常定义服务器连接的详细情况,但是 实际的名称和值依赖于服务器的外部数据的封装器。

注意

When using the dblink module (see Section F.8), the foreign server name can be used as an argument of the dblink_connect function to indicate the connection parameters. See also there for more examples. It is necessary to have the USAGE privilege on the foreign server to be able to use it in this way. 当使用dblink模块(参阅Section F.8), 外部服务器名称可以用作一个dblink_connect函数的参数 来表示连接参数。参见更多示例。为了能够以这种方式使用它,有必要在外服务器上拥有 USAGE权限。

示例

创建一个使用内置的外部数据封装器default的服务器foo

CREATE SERVER foo FOREIGN DATA WRAPPER "default";

创建一个使用外部数据封装器pgsql的服务器myserver

CREATE SERVER myserver FOREIGN DATA WRAPPER pgsql OPTIONS (host 'foo', dbname 'foodb', port '5432');

兼容性

CREATE SERVER符合于ISO/IEC 9075-9 (SQL/MED).

又见

ALTER SERVER, DROP SERVER, CREATE FOREIGN DATA WRAPPER, CREATE USER MAPPING