PostgreSQL implements part of the sql/med specification, allowing SQL queries that use rules to access data residing outside of PostgreSQL. Such data is referred to as external data . (Note that this usage cannot be confused with foreign keys, which are a constraint type for the database.) )
External data is accessed through the help of an external data wrapper . An external data wrapper is a library that communicates with external data sources, hides the details of connections to external data sources, and obtains data from external data sources. Here are a few available external data wrappers as a contribution template. Other types of external data wrappers may be seen in third-party products. If the existing external data wrapper does not fit your needs.
To access external data, you need to create an external server object that defines how to connect to a specific external data source based on the options set by the supported external data wrapper. Then you need to create one or more external tables that define the structure of the remote data. An external table can be used for queries like normal tables, but external tables are not stored in the PostgreSQL server. Whenever an external table is used,PostgreSQL requires an external data wrapper to fetch data from an external source, or to transfer data to an external source when the command is updated.
Accessing remote data may require validation to an external data source. This information can be provided through a user mapping , which can provide additional data, such as user name and password, based on the current PostgreSQL role.
PostgreSQL External Data