Swastik Raj Ghosh
Swastik Raj Ghosh

Reputation: 668

Replace view in Snowflake

I created a view (Let's say 'ViewA') and I want to replace it, what supporting syntax do we have? I went through the documentation, maybe not thoroughly enough, and found nothing.

I got this: https://docs.snowflake.net/manuals/sql-reference/sql/create-view.html#syntax

But this is of little help.

These are the commands I am using:

CREATE VIEW view_name (alias_1, alias_2) AS
 SELECT col_1, col_2
 FROM table
 WHERE col_3 > 2;


 alter VIEW view_name (alias_1, alias_2) AS
 SELECT col_1 as 'Employee Name', 
 col_2 as 'alias_3'
 FROM table
 WHERE col_3 > 2;

Upvotes: 2

Views: 6128

Answers (1)

Marcin Zukowski
Marcin Zukowski

Reputation: 4719

You can use the CREATE OR REPLACE syntax, documented on the page you linked. Example:

create or replace VIEW view_name (alias_1, alias_2) AS
SELECT col_1 as 'Employee Name', 
col_2 as 'alias_3'
FROM table
WHERE col_3 > 2

This should be an atomic operation.

If this is not what you're looking for, please explain what you mean by "replace" exactly.

Upvotes: 6

Related Questions