0
votes

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;
1
Drop it and create a new view.jarlh
i did, but still I am not able to replace it. I am eager to know it's syntax for future use. This is the error I'm getting -> 'SQL compilation error: syntax error line 1 at position 1 unexpected 'REPLACE'.'Swastik Raj Ghosh
There is no such alter view functionality.jarlh
Can you post the command as you are writing it?etsa
In doc you cited, you can read: ALTER VIEW Modifies the properties for an existing view. Currently the only supported operations are renaming a view, converting/reverting a secure view, and adding/overwriting/removing a comment for a view.etsa

1 Answers

4
votes

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.