CREATE VIEW

Translation from Greenplum to Snowflake

Description

This command creates a view in a database, which is run every time the view is referenced in a query.

For more information, please refer to CREATE VIEW documentation.

Grammar Syntax

CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW <name> [ ( <column_name> [, ...] ) ]
    [ WITH ( view_option_name [= view_option_value] [, ... ] ) ]
    AS <query>
    [ WITH [ CASCADED | LOCAL ] CHECK OPTION ]

Code Examples

[OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE]

Input Code:

IN -> Greenplum_01.sql
CREATE OR REPLACE VIEW view1 AS
    SELECT
        product_id,
        SUM(quantity) AS sum_quantity
    FROM
        table1
    GROUP BY
        product_id;

CREATE TEMPORARY RECURSIVE VIEW view2 AS
    SELECT
        product_id,
        SUM(quantity) AS sum_quantity
    FROM
        table1
    GROUP BY
        product_id;

Output Code:

OUT -> Greenplum_01.sql
CREATE OR REPLACE VIEW view1
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "greenplum",  "convertedOn": "04/24/2025",  "domain": "test" }}'
AS
    SELECT
        product_id,
        SUM(quantity) AS sum_quantity
    FROM
        table1
GROUP BY
        product_id;


CREATE TEMPORARY RECURSIVE VIEW view2
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "greenplum",  "convertedOn": "04/24/2025",  "domain": "test" }}'
AS
    SELECT
        product_id,
        SUM(quantity) AS sum_quantity
    FROM
        table1
GROUP BY
        product_id;

Last updated