ALTER SEQUENCE
- Last Updated: March 30, 2020
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
The ALTER SEQUENCE statement
can be used to change the current value of an existing sequence.
The sequence can be in the current schema or a schema can be specified.
When
altering a sequence of a multi-tenant table as a regular tenant,
the FOR TENANT phrase is optional to modify its CURRVAL,
and a regular tenant does not have the privileges to modify the
global attributes of a sequence.
When altering the sequence
of a multi-tenant table as a DBA or a super-tenant, the FOR
TENANT phrase is mandatory for a DBA or a super-tenant
to identify the tenant in the multi-tenant database that must be
altered. A DBA or a super-tenant can alter all the sequence attributes
of a multi-tenant table.
Syntax
|
- schema_name
- Specifies the name of the schema name that contains the sequence. If this is not specified, OpenEdge SQL alters the sequence.
- sequence_name
- Specifies the sequence to be altered.
- CURRVAL
- Returns the current value of the sequence.
-
FOR TENANTtenant_name - Specifies the name of the tenant corresponding to the CURRVAL.
- INCREMENT BY
- Specifies the interval between sequence numbers. The value can
be a positive or negative integer (
INTEGERdata type for 32-bit sequences,BIGINTdatatype for 64-bit sequences), but it cannot be 0. The value range for a 32-bit sequence is -2,147,483,648 to 2,147,483,647. The value range for a 64-bit sequence is -9223372036854775808 to 9223372036854775807. The value is positive for an ascending sequence and negative for a descending sequence. The default value is 1. -
START WITH - Specifies the first number in a sequence generated. The value
must be greater than or equal to the
MINVALUEfor an ascending sequence. The value must be less than or equal to theMAXVALUEfor a descending sequence. The default value for an ascending sequence isMINVALUEandMAXVALUEfor a descending sequence. - MAXVALUE
-
Specifies the maximum value that the sequence can generate. The default value is -1 for both 32-bit and 64-bit descending sequences. The default value is 2,147,483,647 for a 32-bit ascending sequence and 9223372036854775807 for a 64-bit ascending sequence.
- NOMAXVALUE
-
Specifies -1 as the
MAXVALUEfor a 32-bit descending sequence and 2,147,483,647 as theMAXVALUEfor a 32-bit ascending sequence. Specifies -1 as theMAXVALUEfor a 64-bit descending sequence and 9223372036854775807 as theMAXVALUEfor a 64-bit ascending sequence. - MINVALUE
-
Specifies the minimum value that the sequence can generate. The default value is 0 for an ascending sequence. The default value is -2,147,483,6480 for a 32-bit descending sequence and -9223372036854775808 for a 64-bit sequence.
- NOMINVALUE
-
Specifies 0 as the
MINVALUEfor an ascending sequence. TheMINVALUEis -2,147,483,648 for a 32-bit descending sequence and -9223372036854775808 for a 64-bit sequence. - CYCLE
-
Indicates that the sequence will continue to generate values after attaining the
MAXVALUE(for an ascending sequence)orMINVALUE(for a descending sequence). - NOCYCLE
-
Indicates that the sequence cannot generate more values after attaining the
MAXVALUE(for an ascending sequence) orMINVALUE(for a descending sequence). The SQL sequence generator usesNOCYCLEas the default ifCYCLEis not specified.
Notes
- It is possible to set only one attribute of a sequence at a time.
- Attributes
START WITH,INCREMENT BY,MAXVALUE,MINVALUEandCURRVALcan take either anINTEGERorBIGINTargument, depending on whether the sequence is a 32-bit or a 64-bit sequence.
Examples
The following example modifies a sequence by specifying a maximum value:
|
The following example when executed by a DBA or a super-tenant, modifies a sequence of a multi-tenant table by specifying a maximum value:
|
The following example when executed by a DBA
or a super-tenant, modifies a sequence by specifying a CURRVAL for
the tenant AsiaPecificCust of a multi-tenant table:
|