views
Creates, updates, deletes, gets or lists a views
resource.
Overview
Name | views |
Type | Resource |
Id | snowflake.view.views |
Fields
The following fields are returned by SELECT
queries:
- list_views
- fetch_view
A Snowflake view
Name | Datatype | Description |
---|---|---|
name | string | Name of the view |
database_name | string | Database in which the view is stored |
schema_name | string | Schema in which the view is stored |
columns | array | The columns of the view |
comment | string | user comment associated to an object in the dictionary |
created_on | string (date-time) | Date and time when the view was created. |
kind | string | Kind of the view, permanent (default) or temporary |
owner | string | Role that owns the view |
owner_role_type | string | The type of role that owns the view |
query | string | Query used to create the view |
recursive | boolean | Whether or not this view can refer to itself using recursive syntax withot requiring a CTE (common table expression) |
secure | boolean | Whether or not this view is secure |
A Snowflake view
Name | Datatype | Description |
---|---|---|
name | string | Name of the view |
database_name | string | Database in which the view is stored |
schema_name | string | Schema in which the view is stored |
columns | array | The columns of the view |
comment | string | user comment associated to an object in the dictionary |
created_on | string (date-time) | Date and time when the view was created. |
kind | string | Kind of the view, permanent (default) or temporary |
owner | string | Role that owns the view |
owner_role_type | string | The type of role that owns the view |
query | string | Query used to create the view |
recursive | boolean | Whether or not this view can refer to itself using recursive syntax withot requiring a CTE (common table expression) |
secure | boolean | Whether or not this view is secure |
Methods
The following methods are available for this resource:
Name | Accessible by | Required Params | Optional Params | Description |
---|---|---|---|---|
list_views | select | database_name , schema_name , endpoint | like , startsWith , showLimit , fromName , deep | List views |
fetch_view | select | database_name , schema_name , name , endpoint | Fetch a view | |
create_view | insert | database_name , schema_name , endpoint | createMode , copyGrants | Create a view |
delete_view | delete | database_name , schema_name , name , endpoint | ifExists | Delete a view |
Parameters
Parameters can be passed in the WHERE
clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
Name | Datatype | Description |
---|---|---|
database_name | string | Identifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases. |
endpoint | string | Organization and Account Name (default: orgid-acctid) |
name | string | Identifier (i.e. name) for the resource. |
schema_name | string | Identifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database. |
copyGrants | boolean | Query parameter to enable copy grants when creating the object. |
createMode | string | Query parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists : Throws an error if you try to create a resource that already exists. - orReplace : Automatically replaces the existing resource with the current one. - ifNotExists : Creates a new resource when an alter is requested for a non-existent resource. |
deep | boolean | Optionally includes dependency information of the view. |
fromName | string | Query parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name. |
ifExists | boolean | Query parameter that specifies how to handle the request for a resource that does not exist: - true : The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false : The endpoint throws an error if the resource doesn't exist. |
like | string | Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters. |
showLimit | integer | Query parameter to limit the maximum number of rows returned by a command. |
startsWith | string | Query parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching. |
SELECT
examples
- list_views
- fetch_view
List views
SELECT
name,
database_name,
schema_name,
columns,
comment,
created_on,
kind,
owner,
owner_role_type,
query,
recursive,
secure
FROM snowflake.view.views
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}'
AND deep = '{{ deep }}';
Fetch a view
SELECT
name,
database_name,
schema_name,
columns,
comment,
created_on,
kind,
owner,
owner_role_type,
query,
recursive,
secure
FROM snowflake.view.views
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required;
INSERT
examples
- create_view
- Manifest
Create a view
INSERT INTO snowflake.view.views (
data__name,
data__secure,
data__kind,
data__recursive,
data__columns,
data__comment,
data__query,
database_name,
schema_name,
endpoint,
createMode,
copyGrants
)
SELECT
'{{ name }}' --required,
{{ secure }},
'{{ kind }}',
{{ recursive }},
'{{ columns }}' --required,
'{{ comment }}',
'{{ query }}' --required,
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}',
'{{ copyGrants }}'
;
# Description fields are for documentation purposes
- name: views
props:
- name: database_name
value: string
description: Required parameter for the views resource.
- name: schema_name
value: string
description: Required parameter for the views resource.
- name: endpoint
value: string
description: Required parameter for the views resource.
- name: name
value: string
description: >
Name of the view
- name: secure
value: boolean
description: >
Whether or not this view is secure
- name: kind
value: string
description: >
Kind of the view, permanent (default) or temporary
valid_values: ['PERMANENT', 'TEMPORARY']
- name: recursive
value: boolean
description: >
Whether or not this view can refer to itself using recursive syntax withot requiring a CTE (common table expression)
- name: columns
value: array
description: >
The columns of the view
- name: comment
value: string
description: >
user comment associated to an object in the dictionary
- name: query
value: string
description: >
Query used to create the view
- name: createMode
value: string
description: Query parameter allowing support for different modes of resource creation. Possible values include: - `errorIfExists`: Throws an error if you try to create a resource that already exists. - `orReplace`: Automatically replaces the existing resource with the current one. - `ifNotExists`: Creates a new resource when an alter is requested for a non-existent resource.
- name: copyGrants
value: boolean
description: Query parameter to enable copy grants when creating the object.
DELETE
examples
- delete_view
Delete a view
DELETE FROM snowflake.view.views
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';