CREATE FOREIGN DATA WRAPPER SQL - Language Statements CREATE FOREIGN DATA WRAPPER define a new foreign-data wrapper CREATE FOREIGN DATA WRAPPER CREATE FOREIGN DATA WRAPPER name LIBRARY 'libraryname' LANGUAGE C [ OPTIONS ( option 'value' [, ... ] ) ] Description CREATE FOREIGN DATA WRAPPER creates a new foreign-data wrapper. The user who defines a foreign-data wrapper becomes its owner. The foreign-data wrapper name must be unique within the database. Only superusers can create foreign-data wrappers. Parameters name The name of the foreign-data wrapper to be created. libraryname The name of the shared library implementing the foreign-data wrapper. The file name is specified in the same way as for shared library names in ; in particular, one can rely on a search path and automatic addition of the system's standard shared library file name extension. LANGUAGE C Currently, only the C programming language is supported for implementing foreign-data wrappers. OPTIONS ( option ['value'] [, ... ] ) This clause specifies options for the new foreign-data wrapper. The allowed option names and values are specific to each foreign data wrapper and are validated using the foreign-data wrapper library. Option names must be unique. Notes At the moment, the foreign-data wrapper functionality is very rudimentary. The purpose of foreign-data wrappers, foreign servers, and user mappings is to store this information in a standard way so that it can be queried by interested applications. The functionality to actually query external data does not exist yet. The C language API for foreign-data wrappers is currently not documented, stable, or complete. Would-be authors of functionality interfacing with the SQL/MED functionality are advised to contact the PostgreSQL developers. There are currently two foreign-data wrapper libraries provided: dummy_fdw, which does nothing and could be useful for testing, and postgresql_fdw, which accepts options corresponding to libpq connection parameters. Examples Create a foreign-data wrapper dummy with library dummy_fdw: CREATE FOREIGN DATA WRAPPER dummy LIBRARY 'dummy_fdw' LANGUAGE C; Create a foreign-data wrapper postgresql with library postgresql_fdw: CREATE FOREIGN DATA WRAPPER postgresql LIBRARY 'postgresql_fdw' LANGUAGE C; Create a foreign-data wrapper mywrapper with library /home/bob/mywrapper.so and some options: CREATE FOREIGN DATA WRAPPER mywrapper LIBRARY '/home/bob/mywrapper.so' LANGUAGE C OPTIONS (debug 'true'); Compatibility CREATE FOREIGN DATA WRAPPER conforms to ISO/IEC 9075-9 (SQL/MED), with the exception that the LIBRARY clause is not optional in PostgreSQL. Note, however, that the SQL/MED functionality as a whole is not yet conforming. See Also