]> begriffs open source - ai-pg/blob - full-docs/txt/ddl-foreign-data.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / ddl-foreign-data.txt
1
2 5.13. Foreign Data #
3
4    PostgreSQL implements portions of the SQL/MED specification, allowing
5    you to access data that resides outside PostgreSQL using regular SQL
6    queries. Such data is referred to as foreign data. (Note that this
7    usage is not to be confused with foreign keys, which are a type of
8    constraint within the database.)
9
10    Foreign data is accessed with help from a foreign data wrapper. A
11    foreign data wrapper is a library that can communicate with an external
12    data source, hiding the details of connecting to the data source and
13    obtaining data from it. There are some foreign data wrappers available
14    as contrib modules; see Appendix F. Other kinds of foreign data
15    wrappers might be found as third party products. If none of the
16    existing foreign data wrappers suit your needs, you can write your own;
17    see Chapter 58.
18
19    To access foreign data, you need to create a foreign server object,
20    which defines how to connect to a particular external data source
21    according to the set of options used by its supporting foreign data
22    wrapper. Then you need to create one or more foreign tables, which
23    define the structure of the remote data. A foreign table can be used in
24    queries just like a normal table, but a foreign table has no storage in
25    the PostgreSQL server. Whenever it is used, PostgreSQL asks the foreign
26    data wrapper to fetch data from the external source, or transmit data
27    to the external source in the case of update commands.
28
29    Accessing remote data may require authenticating to the external data
30    source. This information can be provided by a user mapping, which can
31    provide additional data such as user names and passwords based on the
32    current PostgreSQL role.
33
34    For additional information, see CREATE FOREIGN DATA WRAPPER, CREATE
35    SERVER, CREATE USER MAPPING, CREATE FOREIGN TABLE, and IMPORT FOREIGN
36    SCHEMA.