1CREATE FOREIGN DATA WRAPPEPRo(s7t)greSQL 14.3 DocumentCaRtEiAoTnE FOREIGN DATA WRAPPER(7)
2
3
4

NAME

6       CREATE_FOREIGN_DATA_WRAPPER - define a new foreign-data wrapper
7

SYNOPSIS

9       CREATE FOREIGN DATA WRAPPER name
10           [ HANDLER handler_function | NO HANDLER ]
11           [ VALIDATOR validator_function | NO VALIDATOR ]
12           [ OPTIONS ( option 'value' [, ... ] ) ]
13

DESCRIPTION

15       CREATE FOREIGN DATA WRAPPER creates a new foreign-data wrapper. The
16       user who defines a foreign-data wrapper becomes its owner.
17
18       The foreign-data wrapper name must be unique within the database.
19
20       Only superusers can create foreign-data wrappers.
21

PARAMETERS

23       name
24           The name of the foreign-data wrapper to be created.
25
26       HANDLER handler_function
27           handler_function is the name of a previously registered function
28           that will be called to retrieve the execution functions for foreign
29           tables. The handler function must take no arguments, and its return
30           type must be fdw_handler.
31
32           It is possible to create a foreign-data wrapper with no handler
33           function, but foreign tables using such a wrapper can only be
34           declared, not accessed.
35
36       VALIDATOR validator_function
37           validator_function is the name of a previously registered function
38           that will be called to check the generic options given to the
39           foreign-data wrapper, as well as options for foreign servers, user
40           mappings and foreign tables using the foreign-data wrapper. If no
41           validator function or NO VALIDATOR is specified, then options will
42           not be checked at creation time. (Foreign-data wrappers will
43           possibly ignore or reject invalid option specifications at run
44           time, depending on the implementation.) The validator function must
45           take two arguments: one of type text[], which will contain the
46           array of options as stored in the system catalogs, and one of type
47           oid, which will be the OID of the system catalog containing the
48           options. The return type is ignored; the function should report
49           invalid options using the ereport(ERROR) function.
50
51       OPTIONS ( option 'value' [, ... ] )
52           This clause specifies options for the new foreign-data wrapper. The
53           allowed option names and values are specific to each foreign data
54           wrapper and are validated using the foreign-data wrapper's
55           validator function. Option names must be unique.
56

NOTES

58       PostgreSQL's foreign-data functionality is still under active
59       development. Optimization of queries is primitive (and mostly left to
60       the wrapper, too). Thus, there is considerable room for future
61       performance improvements.
62

EXAMPLES

64       Create a useless foreign-data wrapper dummy:
65
66           CREATE FOREIGN DATA WRAPPER dummy;
67
68       Create a foreign-data wrapper file with handler function
69       file_fdw_handler:
70
71           CREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler;
72
73       Create a foreign-data wrapper mywrapper with some options:
74
75           CREATE FOREIGN DATA WRAPPER mywrapper
76               OPTIONS (debug 'true');
77

COMPATIBILITY

79       CREATE FOREIGN DATA WRAPPER conforms to ISO/IEC 9075-9 (SQL/MED), with
80       the exception that the HANDLER and VALIDATOR clauses are extensions and
81       the standard clauses LIBRARY and LANGUAGE are not implemented in
82       PostgreSQL.
83
84       Note, however, that the SQL/MED functionality as a whole is not yet
85       conforming.
86

SEE ALSO

88       ALTER FOREIGN DATA WRAPPER (ALTER_FOREIGN_DATA_WRAPPER(7)), DROP
89       FOREIGN DATA WRAPPER (DROP_FOREIGN_DATA_WRAPPER(7)), CREATE SERVER
90       (CREATE_SERVER(7)), CREATE USER MAPPING (CREATE_USER_MAPPING(7)),
91       CREATE FOREIGN TABLE (CREATE_FOREIGN_TABLE(7))
92
93
94
95PostgreSQL 14.3                      2022       CREATE FOREIGN DATA WRAPPER(7)
Impressum