YMatrix
Quick Start
Simulate Time Series Scenarios
Standard Cluster Deployment
Data Modeling
Connecting to The database
Data Writing
Data Migration
Data Query
Scene Application Examples
Federal Query
Maintenance and Monitoring
Global Maintenance
Partition Maintenance
Backup and Restore
Cluster Expansion
Enable Mirroring
Resource Management
Security
Monitoring
Performance Tuning
Troubleshooting
Reference Guide
Tool Guide
Data Type
Storage Engine
Execution Engine
Stream Processing
DR (Disaster Recovery)
Configuration Parameters
Index
Extension
SQL Reference
FAQ
Define a new appearance.
CREATE FOREIGN TABLE [ IF NOT EXISTS ] table_name ( [
column_name data_type [ OPTIONS ( option 'value' [, ... ] ) ] [ COLLATE collation ] [ column_constraint [ ... ] ]
[, ... ]
] )
SERVER server_name
[ OPTIONS ( [ mpp_execute { 'master' | 'any' | 'all segments' } [, ] ] option 'value' [, ... ] ) ]
where column_constraint is:
[ CONSTRAINT constraint_name ]
{ NOT NULL |
NULL |
DEFAULT default_expr }
CREATE FOREIGN TABLE Creates a new external table in the current database. The user who creates an external table will become its owner.
If you schema qualify table names (for example, CREATE FOREIGN TABLE myschema.mytable ...), the YMatrix database creates the table in the specified schema. Otherwise, an external table is created in the current schema. The name of the external table must be different from the name of any other external table, table, sequence, index, or view in the same schema.
Because CREATE FOREIGN TABLE automatically creates a data type that represents a composite type corresponding to a row of the external table, the external table cannot have the same name as any existing data type in the same schema.
To create an external table, you must have USAGE privileges on the external server and have USAGE privileges for all column types used in the table.
IF NOT EXISTS
table_name
column_name
data_type
NOT NULL
NULL
DEFAULT default_expr
server_name
OPTIONS ( option 'value' [, ... ] )
mpp_execute { 'master' | 'any' | 'all segments' }
Create an external table named films using a server named film_server:
CREATE FOREIGN TABLE films (
code char(5) NOT NULL,
title varchar(40) NOT NULL,
did integer NOT NULL,
date_prod date,
kind varchar(10),
len interval hour to minute
)
SERVER film_server;
CREATE FOREIGN TABLE is basically SQL-compliant; however, like CREATE TABLE, the YMatrix database allows NULL constraints and zero-column external tables. The function of specifying default values is the YMatrix database extension, and the mpp_execute option.