Create View
Usage
Views can be created only in virtual schemas, for example, in the default schema views
. Once created, they will appear in the respective virtual schemas section of the Data Virtuality Studio. An existing view will be replaced If CREATE OR REPLACE
is used. An existing view will not be replaced if the view definition (including formatting and comments) has not changed.
CREATE [OR REPLACE] [PRIVATE] VIEW <schema_name>.<viewname>[column_name column_type, ..., PRIMARY KEY(column_name)] AS queryExpression;;
Syntax Rules
PRIMARY KEY
, which uniquely identifies each record in a table, must contain a unique value and cannot be null;- The number of columns in
queryExpression
must not be changed.
The PRIVATE
keyword is reserved for internal use and should not be specified for user-defined views.
Examples
CREATE VIEW views.countryregion AS
SELECT *
FROM adventureworks.countryregion ;;
CREATE VIEW virtual_schema_name.creditcard AS
SELECT number, expiryDate, ccv
FROM adventureworks.creditcard ;;
CREATE VIEW virtual_schema_name.creditcard(number integer, expiryDate date, PRIMARY KEY(number)) AS
SELECT number, expiryDate
FROM adventureworks.creditcard ;;
State
Once a view has been created, it will have one of the following states:
State | Description |
---|---|
READY | The view can be used |
WARNING | The view can be used, but the backing data source uses a stored copy of the metadata.
|
FAILED | The view failed to load. A view in this state cannot be used |