Skip to main content

sequences

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

Overview

Namesequences
TypeResource
Idsnowflake.pipelines.sequences

Fields

The following fields are returned by SELECT queries:

successful

NameDatatypeDescription
namestringName of the sequence (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
database_namestringDatabase in which the sequence is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
schema_namestringSchema in which the sequence is stored (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
commentstringComment for the sequence
created_onstring (date-time)Date and time when the sequence was created.
incrementinteger (int64)Step interval of the sequence
orderedbooleanWhether or not the values are generated in increasing or decreasing order
ownerstringRole that owns the sequence (pattern: ^"([^"]|"")+"|[a-zA-Z_][a-zA-Z0-9_$]*$)
owner_role_typestringThe type of role that owns the sequence
startinteger (int64)First value returned by the sequence

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdatabase_name, schema_name, name, endpointFetch a sequence
listselectdatabase_name, schema_name, endpointlikeList sequences
createinsertdatabase_name, schema_name, endpoint, namecreateModeCreate a sequence
deletedeletedatabase_name, schema_name, name, endpointifExistsDelete a sequence
cloneexecdatabase_name, schema_name, name, endpoint, namecreateMode, targetDatabase, targetSchemaCreate a new sequence by cloning from the specified resource
renameexecdatabase_name, schema_name, name, targetName, endpointifExists, targetDatabase, targetSchemaRename a sequence with a new identifier

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.

NameDatatypeDescription
database_namestringIdentifier (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.
endpointstringOrganization and account identifier (orgname-accountname) (default: orgname-accountname)
namestringIdentifier (i.e. name) for the resource.
schema_namestringIdentifier (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.
targetNamestringName of the target resource.
createModestringParameter 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.
ifExistsbooleanParameter 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.
likestringParameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
targetDatabasestringDatabase of the target resource. Defaults to the source's database
targetSchemastringSchema of the target resource. Defaults to the source's schema

SELECT examples

Fetch a sequence

SELECT
name,
database_name,
schema_name,
comment,
created_on,
increment,
ordered,
owner,
owner_role_type,
start
FROM snowflake.pipelines.sequences
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND name = '{{ name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

INSERT examples

Create a sequence

INSERT INTO snowflake.pipelines.sequences (
start,
increment,
ordered,
comment,
name,
database_name,
schema_name,
endpoint,
createMode
)
SELECT
{{ start }},
{{ increment }},
{{ ordered }},
'{{ comment }}',
'{{ name }}' /* required */,
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}'
RETURNING
status
;

DELETE examples

Delete a sequence

DELETE FROM snowflake.pipelines.sequences
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}'
;

Lifecycle Methods

Create a new sequence by cloning from the specified resource

EXEC snowflake.pipelines.sequences.clone
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@endpoint='{{ endpoint }}' --required,
@createMode='{{ createMode }}',
@targetDatabase='{{ targetDatabase }}',
@targetSchema='{{ targetSchema }}'
@@json=
'{
"start": {{ start }},
"increment": {{ increment }},
"ordered": {{ ordered }},
"comment": "{{ comment }}",
"name": "{{ name }}"
}'
;