Skip to main content
Skip table of contents

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.

SQL
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

SQL
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:

StateDescription
READYThe view can be used
WARNING

The view can be used, but the backing data source uses a stored copy of the metadata.

(info) Most probably, the data source was unavailable when the Data Virtuality Server started or during the last metadata refresh. To fix this, it is usually enough to refresh the underlying data source

FAILEDThe view failed to load. A view in this state cannot be used
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.