CREATE EXTERNAL VIEW - Amazon Redshift

CREATE EXTERNAL VIEW

The Data Catalog views preview feature is available only in the following Regions.

  • US East (Ohio) (us-east-2)

  • US East (N. Virginia) (us-east-1)

  • US West (N. California) (us-west-1)

  • Asia Pacific (Tokyo) (ap-northeast-1)

  • Europe (Ireland) (eu-west-1)

  • Europe (Stockholm) (eu-north-1)

Creates a view in the Data Catalog. Data Catalog views are a single view schema that works with other SQL engines such as Amazon Athena and Amazon EMR. You can query the view from your choice of engine. For more information about Data Catalog views, see Creating Data Catalog views.

Syntax

CREATE EXTERNAL VIEW schema_name.view_name [ IF NOT EXISTS ] {catalog_name.schema_name.view_name | awsdatacatalog.dbname.view_name | external_schema_name.view_name} AS query_definition;

Parameters

schema_name.view_name

The schema that’s attached to your AWS Glue database, followed by the name of the view.

PROTECTED

Specifies that the CREATE EXTERNAL VIEW command should only complete if the query within the query_definition can successfully complete.

IF NOT EXISTS

Creates the view if the view doesn’t already exist.

catalog_name.schema_name.view_name | awsdatacatalog.dbname.view_name | external_schema_name.view_name

The notation of the schema to use when creating the view. You can specify to use the AWS Glue Data Catalog, a Glue database that you created, or an external schema that you created. See CREATE DATABASE and CREATE EXTERNAL SCHEMA for more information.

query_definition

The definition of the SQL query that Amazon Redshift runs to alter the view.

Examples

The following example creates a Data Catalog view named sample_schema.glue_data_catalog_view.

CREATE EXTERNAL PROTECTED VIEW sample_schema.glue_data_catalog_view IF NOT EXISTS AS SELECT * FROM sample_database.remote_table "remote-table-name";