CREATE VIEW

Description

This command creates a view in a database, which is run every time the view is referenced in a query. Using the WITH NO SCHEMA BINDING clause, you can create views to an external table or objects that don't exist yet. This clause, however, requires you to specify the qualified name of the object or table that you are referencing.

Grammar Syntax

The following is the SQL syntax to create a view in Amazon Redshift. Click here to here to go to Redshifts specification for this syntax.

CREATE [ OR REPLACE ] VIEW name [ ( column_name [, ...] ) ] AS query
[ WITH NO SCHEMA BINDING ]               

Sample Source Patterns

Considering the obligatory and optional clauses in Redshifts command, the output after migration to Snowflake is very similar.

Input Code:

IN -> Redshift_01.sql
CREATE VIEW myuser
AS 
SELECT lastname FROM users;


CREATE VIEW myuser2
AS 
SELECT lastname FROM users2
WITH NO SCHEMA BINDING;

Output Code:

OUT -> Redshift_01.sql
CREATE VIEW myuser
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "01/16/2025",  "domain": "test" }}'
AS
SELECT lastname FROM
users;

CREATE VIEW myuser2
COMMENT = '{ "origin": "sf_sc", "name": "snowconvert", "version": {  "major": 0,  "minor": 0,  "patch": "0" }, "attributes": {  "component": "redshift",  "convertedOn": "01/16/2025",  "domain": "test" }}'
AS
SELECT lastname FROM
users2
!!!RESOLVE EWI!!! /*** SSC-EWI-RS0003 - WITH NO SCHEMA BINDING STATEMENT CAN NOT BE REMOVED DUE TO MISSING REFERENCES. ***/!!!
WITH NO SCHEMA BINDING;

There are some exceptions, however, of one unsupported clause from Redshift, therefore an EWI was implemented to cover this case.

  • SSC-EWI-RS0003: With no schema binding statement is not supported in Snowflake.

Last updated