Skip to main content

views

Creates, updates, deletes, gets or lists a views resource.

Overview

Nameviews
TypeResource
Idsnowflake.view.views

Fields

NameDatatypeDescription
namestringName of the view
columnsarrayThe columns of the view
commentstringuser comment associated to an object in the dictionary
created_onstringDate and time when the view was created.
database_namestringDatabase in which the view is stored
kindstringKind of the view, permanent (default) or temporary
ownerstringRole that owns the view
owner_role_typestringThe type of role that owns the view
querystringQuery used to create the view
recursivebooleanWhether or not this view can refer to itself using recursive syntax withot requiring a CTE (common table expression)
schema_namestringSchema in which the view is stored
securebooleanWhether or not this view is secure

Methods

NameAccessible byRequired ParamsDescription
fetch_viewSELECTdatabase_name, name, schema_name, endpointFetch a view
list_viewsSELECTdatabase_name, schema_name, endpointList views
create_viewINSERTdatabase_name, schema_name, data__columns, data__name, data__query, endpointCreate a view
delete_viewDELETEdatabase_name, name, schema_name, endpointDelete a view

SELECT examples

List views

SELECT
name,
columns,
comment,
created_on,
database_name,
kind,
owner,
owner_role_type,
query,
recursive,
schema_name,
secure
FROM snowflake.view.views
WHERE database_name = '{{ database_name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';

INSERT example

Use the following StackQL query and manifest file to create a new views resource.

/*+ create */
INSERT INTO snowflake.view.views (
data__name,
data__secure,
data__kind,
data__recursive,
data__columns,
data__comment,
data__query,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ secure }}',
'{{ kind }}',
'{{ recursive }}',
'{{ columns }}',
'{{ comment }}',
'{{ query }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;

DELETE example

Deletes the specified views resource.

/*+ delete */
DELETE FROM snowflake.view.views
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';