Skip to main content

CREATE VIEW

Creates a view within a session which can be used to represent a long or complex stackql query.

See also:
[ SELECT ]


Syntax

creatViewStatement::=

CREATEVIEWASselectStatementJOINselectStatementUNIONselectStatement';'

 

CREATE VIEW AS 
<selectStatement> [ UNION | JOIN <selectStatement> ];

info

Available in version 0.3.x and above.

Examples

Cross cloud UNION between aws and google

CREATE VIEW dual_cloud_block_storage AS
SELECT
'google' AS vendor,
name,
split_part(split_part(type, '/', 11), '-', 2) AS type,
status,
sizeGb AS size
FROM google.compute.disks
WHERE project = '<YOUR_GCP_PROJECT>'
AND zone = 'australia-southeast1-a'
UNION
SELECT
'aws' AS vendor,
volumeId AS name,
volumeType AS type,
status,
size
FROM aws.ec2.volumes
WHERE region = 'ap-southeast-2';