Skip To Content

Create Database Sequence


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


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


CreateDatabaseSequence(in_workspace, seq_name, {seq_start_id}, {seq_inc_value})
ParameterExplanationData Type

The database connection (.sde) file 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 is the owner of the sequence and 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


A name for 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 also 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.


A starting number for 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.


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 increment by 1.


Derived Output

NameExplanationData Type

The updated input workspace.


Code sample

CreateDatabaseSequence example (Python window)

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

import arcpy
                                        "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
                                        "my_ids", 1, 1)


This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: Yes
  • Advanced: Yes

Related topics