2 .\" Title: CREATE FOREIGN DATA WRAPPER
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "CREATE FOREIGN DATA WRAPPER" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 CREATE_FOREIGN_DATA_WRAPPER \- define a new foreign\-data wrapper
35 CREATE FOREIGN DATA WRAPPER \fIname\fR
36 [ HANDLER \fIhandler_function\fR | NO HANDLER ]
37 [ VALIDATOR \fIvalidator_function\fR | NO VALIDATOR ]
38 [ OPTIONS ( \fIoption\fR \*(Aq\fIvalue\fR\*(Aq [, \&.\&.\&. ] ) ]
42 \fBCREATE FOREIGN DATA WRAPPER\fR
43 creates a new foreign\-data wrapper\&. The user who defines a foreign\-data wrapper becomes its owner\&.
45 The foreign\-data wrapper name must be unique within the database\&.
47 Only superusers can create foreign\-data wrappers\&.
52 The name of the foreign\-data wrapper to be created\&.
55 HANDLER \fIhandler_function\fR
57 \fIhandler_function\fR
58 is the name of a previously registered function that will be called to retrieve the execution functions for foreign tables\&. The handler function must take no arguments, and its return type must be
61 It is possible to create a foreign\-data wrapper with no handler function, but foreign tables using such a wrapper can only be declared, not accessed\&.
64 VALIDATOR \fIvalidator_function\fR
66 \fIvalidator_function\fR
67 is the name of a previously registered function that will be called to check the generic options given to the foreign\-data wrapper, as well as options for foreign servers, user mappings and foreign tables using the foreign\-data wrapper\&. If no validator function or
69 is specified, then options will not be checked at creation time\&. (Foreign\-data wrappers will possibly ignore or reject invalid option specifications at run time, depending on the implementation\&.) The validator function must take two arguments: one of type
70 text[], which will contain the array of options as stored in the system catalogs, and one of type
71 oid, which will be the OID of the system catalog containing the options\&. The return type is ignored; the function should report invalid options using the
76 OPTIONS ( \fIoption\fR \*(Aq\fIvalue\fR\*(Aq [, \&.\&.\&. ] )
78 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\*(Aqs validator function\&. Option names must be unique\&.
82 PostgreSQL\*(Aqs foreign\-data functionality is still under active development\&. Optimization of queries is primitive (and mostly left to the wrapper, too)\&. Thus, there is considerable room for future performance improvements\&.
85 Create a useless foreign\-data wrapper
92 CREATE FOREIGN DATA WRAPPER dummy;
98 Create a foreign\-data wrapper
100 with handler function
107 CREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler;
113 Create a foreign\-data wrapper
121 CREATE FOREIGN DATA WRAPPER mywrapper
122 OPTIONS (debug \*(Aqtrue\*(Aq);
129 \fBCREATE FOREIGN DATA WRAPPER\fR
130 conforms to ISO/IEC 9075\-9 (SQL/MED), with the exception that the
134 clauses are extensions and the standard clauses
138 are not implemented in
141 Note, however, that the SQL/MED functionality as a whole is not yet conforming\&.
143 ALTER FOREIGN DATA WRAPPER (\fBALTER_FOREIGN_DATA_WRAPPER\fR(7)), DROP FOREIGN DATA WRAPPER (\fBDROP_FOREIGN_DATA_WRAPPER\fR(7)), CREATE SERVER (\fBCREATE_SERVER\fR(7)), CREATE USER MAPPING (\fBCREATE_USER_MAPPING\fR(7)), CREATE FOREIGN TABLE (\fBCREATE_FOREIGN_TABLE\fR(7))