Skip To Content

Create Database Sequence

Summary

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

Usage

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

Syntax

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

The database connection (.sde) file to connect to the geodatabase in which you want to create a sequence. 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

Workspace
seq_name

A name for the database sequence. The name must meet sequence name requirements for the database platform you're using and must be unique in the database. Be sure to 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)

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.

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

Long

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)

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • ArcGIS Desktop Basic: No
  • ArcGIS Desktop Standard: Yes
  • ArcGIS Desktop Advanced: Yes

Related topics