Table of Contents Previous Next



CREATE FOREIGN TABLE [ IF NOT EXISTS ] table_name ( [
{
column_name data_type [ OPTIONS ( option 'value' [, ... ] ) ] [ COLLATE collation ] [ column_constraint [ ... ] ]
|
table_constraint }
[, ... ]
] )
[ INHERITS (
parent_table [, ... ] ) ]
SERVER
server_name [ OPTIONS ( option 'value' [, ... ] ) ]

where column_constraint is:

[ CONSTRAINT
constraint_name ]
{
NOT NULL | NULL | CHECK (expr) [ NO INHERIT ] | DEFAULT default_expr }

and
table_constraint is:

[ CONSTRAINT
constraint_name ] CHECK (expr) [ NO INHERIT ]
IF NOT EXISTS
Include the IF NOT EXISTS clause to instruct the server to not throw an error if a table with the same name already exists; if a table with the same name exists, the server will issue a notice.
data_type
COLLATE collation
Include the COLLATE clause to assign a collation to the column; if not specified, the column data type's default collation is used.
INHERITS (parent_table [, ... ])
Include the INHERITS clause to specify a list of tables from which the new foreign table automatically inherits all columns. Parent tables can be plain tables or foreign tables.
CONSTRAINT constraint_name
Include the NOT NULL keywords to indicate that the column is not allowed to contain null values.
Include the NULL keywords to indicate that the column is allowed to contain null values. This is the default.
CHECK (expr) [NO INHERIT]
Use the CHECK clause to specify an expression that produces a Boolean result that each row in the table must satisfy. A check constraint specified as a column constraint should reference that column's value only, while an expression appearing in a table constraint can reference multiple columns.
A CHECK expression cannot contain subqueries or refer to variables other than columns of the current row.
Include the NO INHERIT keywords to specify that a constraint should not propagate to child tables.
DEFAULT default_expr
Include the DEFAULT clause to specify a default data value for the column whose column definition it appears within. The data type of the default expression must match the data type of the column.
SERVER server_name [OPTIONS (option 'value' [, ... ] ) ]
To create a foreign table that will allow you to query a table that resides on a Hadoop file system, include the SERVER clause and specify the server_name of the foreign server that uses the Hadoop data adapter.
Use the OPTIONS clause to specify the following options and their corresponding values:
CREATE TABLE weblogs (
client_ip STRING,
full_request_date STRING,
day STRING,
month STRING,
month_num INT,

year STRING,
hour STRING,
minute STRING,
second STRING,
timezone STRING,
http_verb STRING,

uri STRING,
http_status_code STRING,
bytes_returned STRING,
referrer STRING,
user_agent STRING)
row format delimited
fields terminated by '\t';
Include the SERVER clause to specify the name of the database stored on the Hadoop file system (webdata) and the name of the table (weblogs) that corresponds to the table on the Postgres server.
For more information about using the CREATE FOREIGN TABLE command, see:


Table of Contents Previous Next