Create Database Sequence (Data Management)


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.

  • 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.


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

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


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.


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.


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.


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)


Licensing information

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

Related topics