pg_foreign_server

一个存储用于外部数据包装器的外部服务器定义的系统表

pg_foreign_server 是一个 系统目录 表,存储用于 外部数据包装器 (FDW) 的外部服务器定义,这些定义是使用 CREATE SERVER 命令定义的。

pg_foreign_server 添加于 PostgreSQL 8.4 中。

psql 命令

\des 列出外部服务器。

按 PostgreSQL 版本定义

pg_foreign_server (PostgreSQL 17)

          Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Collation | Nullable | Default 
------------+-----------+-----------+----------+---------
 oid        | oid       |           | not null | 
 srvname    | name      |           | not null | 
 srvowner   | oid       |           | not null | 
 srvfdw     | oid       |           | not null | 
 srvtype    | text      | C         |          | 
 srvversion | text      | C         |          | 
 srvacl     | aclitem[] |           |          | 
 srvoptions | text[]    | C         |          | 
Indexes:
    "pg_foreign_server_oid_index" PRIMARY KEY, btree (oid)
    "pg_foreign_server_name_index" UNIQUE CONSTRAINT, btree (srvname)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 16)

          Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Collation | Nullable | Default 
------------+-----------+-----------+----------+---------
 oid        | oid       |           | not null | 
 srvname    | name      |           | not null | 
 srvowner   | oid       |           | not null | 
 srvfdw     | oid       |           | not null | 
 srvtype    | text      | C         |          | 
 srvversion | text      | C         |          | 
 srvacl     | aclitem[] |           |          | 
 srvoptions | text[]    | C         |          | 
Indexes:
    "pg_foreign_server_oid_index" PRIMARY KEY, btree (oid)
    "pg_foreign_server_name_index" UNIQUE CONSTRAINT, btree (srvname)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 15)

          Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Collation | Nullable | Default 
------------+-----------+-----------+----------+---------
 oid        | oid       |           | not null | 
 srvname    | name      |           | not null | 
 srvowner   | oid       |           | not null | 
 srvfdw     | oid       |           | not null | 
 srvtype    | text      | C         |          | 
 srvversion | text      | C         |          | 
 srvacl     | aclitem[] |           |          | 
 srvoptions | text[]    | C         |          | 
Indexes:
    "pg_foreign_server_oid_index" PRIMARY KEY, btree (oid)
    "pg_foreign_server_name_index" UNIQUE CONSTRAINT, btree (srvname)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 14)

          Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Collation | Nullable | Default 
------------+-----------+-----------+----------+---------
 oid        | oid       |           | not null | 
 srvname    | name      |           | not null | 
 srvowner   | oid       |           | not null | 
 srvfdw     | oid       |           | not null | 
 srvtype    | text      | C         |          | 
 srvversion | text      | C         |          | 
 srvacl     | aclitem[] |           |          | 
 srvoptions | text[]    | C         |          | 
Indexes:
    "pg_foreign_server_oid_index" PRIMARY KEY, btree (oid)
    "pg_foreign_server_name_index" UNIQUE CONSTRAINT, btree (srvname)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 13)

          Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Collation | Nullable | Default 
------------+-----------+-----------+----------+---------
 oid        | oid       |           | not null | 
 srvname    | name      |           | not null | 
 srvowner   | oid       |           | not null | 
 srvfdw     | oid       |           | not null | 
 srvtype    | text      | C         |          | 
 srvversion | text      | C         |          | 
 srvacl     | aclitem[] |           |          | 
 srvoptions | text[]    | C         |          | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 12)

          Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Collation | Nullable | Default 
------------+-----------+-----------+----------+---------
 oid        | oid       |           | not null | 
 srvname    | name      |           | not null | 
 srvowner   | oid       |           | not null | 
 srvfdw     | oid       |           | not null | 
 srvtype    | text      | C         |          | 
 srvversion | text      | C         |          | 
 srvacl     | aclitem[] |           |          | 
 srvoptions | text[]    | C         |          | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 11)

          Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Collation | Nullable | Default 
------------+-----------+-----------+----------+---------
 srvname    | name      |           | not null | 
 srvowner   | oid       |           | not null | 
 srvfdw     | oid       |           | not null | 
 srvtype    | text      |           |          | 
 srvversion | text      |           |          | 
 srvacl     | aclitem[] |           |          | 
 srvoptions | text[]    |           |          | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 10)

          Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Collation | Nullable | Default 
------------+-----------+-----------+----------+---------
 srvname    | name      |           | not null | 
 srvowner   | oid       |           | not null | 
 srvfdw     | oid       |           | not null | 
 srvtype    | text      |           |          | 
 srvversion | text      |           |          | 
 srvacl     | aclitem[] |           |          | 
 srvoptions | text[]    |           |          | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 9.6)

Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Modifiers 
------------+-----------+-----------
 srvname    | name      | not null
 srvowner   | oid       | not null
 srvfdw     | oid       | not null
 srvtype    | text      | 
 srvversion | text      | 
 srvacl     | aclitem[] | 
 srvoptions | text[]    | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 9.5)

Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Modifiers 
------------+-----------+-----------
 srvname    | name      | not null
 srvowner   | oid       | not null
 srvfdw     | oid       | not null
 srvtype    | text      | 
 srvversion | text      | 
 srvacl     | aclitem[] | 
 srvoptions | text[]    | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 9.4)

Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Modifiers 
------------+-----------+-----------
 srvname    | name      | not null
 srvowner   | oid       | not null
 srvfdw     | oid       | not null
 srvtype    | text      | 
 srvversion | text      | 
 srvacl     | aclitem[] | 
 srvoptions | text[]    | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 9.3)

Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Modifiers 
------------+-----------+-----------
 srvname    | name      | not null
 srvowner   | oid       | not null
 srvfdw     | oid       | not null
 srvtype    | text      | 
 srvversion | text      | 
 srvacl     | aclitem[] | 
 srvoptions | text[]    | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 9.2)

Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Modifiers 
------------+-----------+-----------
 srvname    | name      | not null
 srvowner   | oid       | not null
 srvfdw     | oid       | not null
 srvtype    | text      | 
 srvversion | text      | 
 srvacl     | aclitem[] | 
 srvoptions | text[]    | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 9.1)

Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Modifiers 
------------+-----------+-----------
 srvname    | name      | not null
 srvowner   | oid       | not null
 srvfdw     | oid       | not null
 srvtype    | text      | 
 srvversion | text      | 
 srvacl     | aclitem[] | 
 srvoptions | text[]    | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 9.0)

Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Modifiers 
------------+-----------+-----------
 srvname    | name      | not null
 srvowner   | oid       | not null
 srvfdw     | oid       | not null
 srvtype    | text      | 
 srvversion | text      | 
 srvacl     | aclitem[] | 
 srvoptions | text[]    | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

pg_foreign_server (PostgreSQL 8.4)

Table "pg_catalog.pg_foreign_server"
   Column   |   Type    | Modifiers 
------------+-----------+-----------
 srvname    | name      | not null
 srvowner   | oid       | not null
 srvfdw     | oid       | not null
 srvtype    | text      | 
 srvversion | text      | 
 srvacl     | aclitem[] | 
 srvoptions | text[]    | 
Indexes:
    "pg_foreign_server_name_index" UNIQUE, btree (srvname)
    "pg_foreign_server_oid_index" UNIQUE, btree (oid)
    

文档: pg_foreign_server

变更历史

PostgreSQL 8.4 添加以来,此表未被修改过。

示例

postgres=# CREATE SERVER fdw_test
  FOREIGN DATA WRAPPER postgres_fdw
  OPTIONS (
    host 'remotehost',
    port '5432',
    dbname 'postgres'
 );
CREATE SERVER

postgres=# SELECT * FROM pg_foreign_server ;
-[ RECORD 1 ]------------------------------------------
oid        | 16459
srvname    | fdw_test
srvowner   | 10
srvfdw     | 16458
srvtype    |
srvversion |
srvacl     |
srvoptions | {host=remotehost,port=5432,dbname=postgres}

srvoptions 中的值可以使用 pg_options_to_table() 提取,例如:

postgres=# SELECT option_name, option_value
             FROM pg_foreign_server,
                  pg_options_to_table(srvoptions)
            WHERE srvname = 'fdw_test';
 option_name | option_value
-------------+--------------
 host        | remotehost
 port        | 5432
 dbname      | postgres
(3 rows)

类别

外部数据包装器 (FDW), 系统目录

另请参阅

CREATE SERVER, ALTER SERVER, DROP SERVER, pg_user_mapping, pg_user_mappings,

反馈

提交关于 "pg_foreign_server" 的任何评论、建议或更正 此处.