CREATE VIEW Statements
To create a new virtual Databricks table, use CREATE VIEW statements.
CREATE VIEW Syntax
The CREATE VIEW statement specifies the name of the new view you would like to create, optionally followed by a list of column aliases, ending with a SQL query defining the resultset from which the view will be derived.
The syntax for CREATE VIEW is as follows:
CREATE [OR REPLACE] VIEW [ IF NOT EXISTS ] view_name
[ column_list ]
AS (<query>)
The following example statement creates a view called "MyContactsView" view in Databricks based on the "contact" table with only its Id, FirstName, and LastName columns:
CREATE VIEW IF NOT EXISTS MyContactsView AS (SELECT Id, FirstName, LastName FROM contact)
You can also include a list of aliases for the columns used in the view-defining query. The number of source table columns and column aliases you provide must be equal.
CREATE VIEW IF NOT EXISTS MyContactsView (Id, FNameAlias, LNameAlias) AS (SELECT Id, FirstName, LastName FROM contact)