Create Database Sequence (Data Management)

Summary

Creates a database sequence in a geodatabase. You can use the sequences in custom applications that access the geodatabase.

Usage

  • This tool can be used with file geodatabases and geodatabases in IBM Db2, Microsoft SQL Server, Oracle, PostgreSQL, and SAP HANA.

  • You can use the ListDatabaseSequences function to get a list of database sequences in a file geodatabase. As sequence names must be unique, getting a list of existing sequences before creating a new one allows you to avoid specifying a name that is already in use.

Parameters

LabelExplanationData Type
Input Workspace

The database connection file (.sde) to connect to the enterprise geodatabase in which you want to create a sequence or the path to the file geodatabase (including the file geodatabase name).

For database connections, the user specified in the database connection will be the owner of the sequence and, therefore, must have the following permissions in the database:

  • Db2—CREATEIN privilege on their schema
  • Oracle—CREATE SEQUENCE system privilege
  • PostgreSQL—Authority on their schema
  • SAP HANA—Must be a standard user
  • SQL Server—CREATE SEQUENCE privilege and ALTER OR CONTROL permission on their schema

Workspace
Sequence Name

The name you want to assign to the database sequence. For enterprise geodatabases, the name must meet sequence name requirements for the database platform you're using and must be unique in the database. For file geodatabases, the name must be unique to the file geodatabase. It is important that you remember this name, as it is the name you use in your custom applications and expressions to invoke the sequence.

String
Sequence Start ID
(Optional)

The starting number of the sequence. If you do not provide a starting number, the sequence starts with 1. If you do provide a starting number, it must be greater than 0.

Long
Sequence Increment Value
(Optional)

Describes how the sequence numbers will increment. For example, if the sequence starts at 10 and the increment value is 5, the next value in the sequence is 15, and the next value after that is 20. If you do not specify an increment value, sequence values will increment by 1.

Long

Derived Output

LabelExplanationData Type
Created sequence in geodatabase

The updated input workspace.

Workspace

arcpy.management.CreateDatabaseSequence(in_workspace, seq_name, {seq_start_id}, {seq_inc_value})
NameExplanationData Type
in_workspace

The database connection file (.sde) to connect to the enterprise geodatabase in which you want to create a sequence or the path to the file geodatabase (including the file geodatabase name).

For database connections, the user specified in the database connection will be the owner of the sequence and, therefore, must have the following permissions in the database:

  • Db2—CREATEIN privilege on their schema
  • Oracle—CREATE SEQUENCE system privilege
  • PostgreSQL—Authority on their schema
  • SAP HANA—Must be a standard user
  • SQL Server—CREATE SEQUENCE privilege and ALTER OR CONTROL permission on their schema

Workspace
seq_name

The name you want to assign to the database sequence. For enterprise geodatabases, the name must meet sequence name requirements for the database platform you're using and must be unique in the database. For file geodatabases, the name must be unique to the file geodatabase. It is important that you remember this name, as it is the name you use in your custom applications and expressions to invoke the sequence.

String
seq_start_id
(Optional)

The starting number of the sequence. If you do not provide a starting number, the sequence starts with 1. If you do provide a starting number, it must be greater than 0.

Long
seq_inc_value
(Optional)

Describes how the sequence numbers will increment. For example, if the sequence starts at 10 and the increment value is 5, the next value in the sequence is 15, and the next value after that is 20. If you do not specify an increment value, sequence values will increment by 1.

Long

Derived Output

NameExplanationData Type
out_workspace

The updated input workspace.

Workspace

Code sample

CreateDatabaseSequence example (Python window)

Create a database sequence named custom_sequence that starts with 1 and increments by 1.

import arcpy
arcpy.CreateDatabaseSequence_management(r"C:/myconnections/mygdb.sde", 
                                        "custom_sequence", 1, 1)
CreateDatabaseSequence example (Python window)

Create a database sequence named my_ids that starts with 1 and increments by 1 in a file geodatabase named myfilegdb.

import arcpy
arcpy.CreateDatabaseSequence_management(r"C:/geodatabases/myfilegdb.gdb", 
                                        "my_ids", 1, 1)

Environments

Related topics