バージョンごとのドキュメント一覧

5.12. 外部データ #

<title>Foreign Data</title>

<productname>PostgreSQL</productname> implements portions of the SQL/MED specification, allowing you to access data that resides outside PostgreSQL using regular SQL queries. Such data is referred to as <firstterm>foreign data</firstterm>. (Note that this usage is not to be confused with foreign keys, which are a type of constraint within the database.) PostgreSQLはSQL/MED仕様を部分的に実装しており、PostgreSQLの外部にあるデータに対して標準的なSQLクエリでアクセスできます。このようなデータは外部データと呼ばれます。(この用語をデータベース内の制約である外部キーと混同しないように気をつけてください。)

Foreign data is accessed with help from a <firstterm>foreign data wrapper</firstterm>. A foreign data wrapper is a library that can communicate with an external data source, hiding the details of connecting to the data source and obtaining data from it. There are some foreign data wrappers available as <filename>contrib</filename> modules; see <xref linkend="contrib"/>. Other kinds of foreign data wrappers might be found as third party products. If none of the existing foreign data wrappers suit your needs, you can write your own; see <xref linkend="fdwhandler"/>. 外部データは外部データラッパーの手助けによりアクセスされます。外部データラッパーは外部データソースと通信できるライブラリであり、接続確立やデータ取得といった詳細を隠蔽します。contribモジュールとして、いくつかの外部データラッパーが利用できます; 付録Fを参照してください。 その他の種類の外部データラッパーは外部製品として見つかるでしょう。既存の外部データラッパーがあなたの用途に合わない場合、独自のラッパーを書くことができます。第59章を参照してください。

To access foreign data, you need to create a <firstterm>foreign server</firstterm> object, which defines how to connect to a particular external data source according to the set of options used by its supporting foreign data wrapper. Then you need to create one or more <firstterm>foreign tables</firstterm>, which define the structure of the remote data. A foreign table can be used in queries just like a normal table, but a foreign table has no storage in the PostgreSQL server. Whenever it is used, <productname>PostgreSQL</productname> asks the foreign data wrapper to fetch data from the external source, or transmit data to the external source in the case of update commands. 外部データにアクセスするには、特定の外部データソースへの接続方法をそれを支える外部データラッパーが使用するオプションの組み合わせによって定義する外部サーバオブジェクトを作成する必要があります。その後、外部データの構造を定義する外部テーブルを少なくともひとつ作成する必要があります。外部テーブルは通常のテーブルと同様にクエリの中で使用できますが、外部テーブルはPostgreSQLサーバに格納領域を持ちません。 外部テーブルが使われるたびに、PostgreSQLは外部ソースからデータを取得することや、更新コマンドの場合には外部ソースへデータを送信することを外部データラッパーに依頼します。

Accessing remote data may require authenticating to the external data source. This information can be provided by a <firstterm>user mapping</firstterm>, which can provide additional data such as user names and passwords based on the current <productname>PostgreSQL</productname> role. 外部データへのアクセスは外部データソースからの認証を必要とする場合があります。この情報は、現在のPostgreSQLロールに基づいてユーザ名やパスワードといった追加のデータを提供できるユーザマッピングによって提供できます。

For additional information, see <xref linkend="sql-createforeigndatawrapper"/>, <xref linkend="sql-createserver"/>, <xref linkend="sql-createusermapping"/>, <xref linkend="sql-createforeigntable"/>, and <xref linkend="sql-importforeignschema"/>. 追加情報は、CREATE FOREIGN DATA WRAPPERCREATE SERVERCREATE USER MAPPINGCREATE FOREIGN TABLEIMPORT FOREIGN SCHEMAを参照してください。