1CREATE FOREIGN TABLE(7) PostgreSQL 9.2.24 DocumentationCREATE FOREIGN TABLE(7)
2
3
4

NAME

6       CREATE_FOREIGN_TABLE - define a new foreign table
7

SYNOPSIS

9       CREATE FOREIGN TABLE [ IF NOT EXISTS ] table_name ( [
10         { column_name data_type [ OPTIONS ( option 'value' [, ... ] ) ] [ NULL | NOT NULL ] }
11           [, ... ]
12       ] )
13         SERVER server_name
14       [ OPTIONS ( option 'value' [, ... ] ) ]
15

DESCRIPTION

17       CREATE FOREIGN TABLE will create a new foreign table in the current
18       database. The table will be owned by the user issuing the command.
19
20       If a schema name is given (for example, CREATE FOREIGN TABLE
21       myschema.mytable ...) then the table is created in the specified
22       schema. Otherwise it is created in the current schema. The name of the
23       foreign table must be distinct from the name of any other foreign
24       table, table, sequence, index, or view in the same schema.
25
26       CREATE FOREIGN TABLE also automatically creates a data type that
27       represents the composite type corresponding to one row of the foreign
28       table. Therefore, foreign tables cannot have the same name as any
29       existing data type in the same schema.
30
31       To be able to create a table, you must have USAGE privilege on all
32       column types.
33

PARAMETERS

35       IF NOT EXISTS
36           Do not throw an error if a relation with the same name already
37           exists. A notice is issued in this case. Note that there is no
38           guarantee that the existing relation is anything like the one that
39           would have been created.
40
41       table_name
42           The name (optionally schema-qualified) of the table to be created.
43
44       column_name
45           The name of a column to be created in the new table.
46
47       data_type
48           The data type of the column. This can include array specifiers. For
49           more information on the data types supported by PostgreSQL, refer
50           to Chapter 8, Data Types, in the documentation.
51
52       NOT NULL
53           The column is not allowed to contain null values.
54
55       NULL
56           The column is allowed to contain null values. This is the default.
57
58           This clause is only provided for compatibility with non-standard
59           SQL databases. Its use is discouraged in new applications.
60
61       server_name
62           The name of an existing server for the foreign table.
63
64       OPTIONS ( option 'value' [, ...] )
65           Options to be associated with the new foreign table or one of its
66           columns. The allowed option names and values are specific to each
67           foreign data wrapper and are validated using the foreign-data
68           wrapper's validator function. Duplicate option names are not
69           allowed (although it's OK for a table option and a column option to
70           have the same name).
71

EXAMPLES

73       Create foreign table films with film_server:
74
75           CREATE FOREIGN TABLE films (
76               code        char(5) NOT NULL,
77               title       varchar(40) NOT NULL,
78               did         integer NOT NULL,
79               date_prod   date,
80               kind        varchar(10),
81               len         interval hour to minute
82           )
83           SERVER film_server;
84

COMPATIBILITY

86       The CREATE FOREIGN TABLE command largely conforms to the SQL standard;
87       however, much as with CREATE TABLE, NULL constraints and zero-column
88       foreign tables are permitted.
89

SEE ALSO

91       ALTER FOREIGN TABLE (ALTER_FOREIGN_TABLE(7)), DROP FOREIGN TABLE
92       (DROP_FOREIGN_TABLE(7)), CREATE TABLE (CREATE_TABLE(7)), CREATE SERVER
93       (CREATE_SERVER(7))
94
95
96
97PostgreSQL 9.2.24                 2017-11-06           CREATE FOREIGN TABLE(7)
Impressum