YMatrix
Quick Start
Simulate Time Series Scenarios
Standard Cluster Deployment
Data Modeling
Connecting to The database
Data Writing
Data Migration
Data Query
Scene Application Examples
Federal Query
Maintenance and Monitoring
Global Maintenance
Partition Maintenance
Backup and Restore
Cluster Expansion
Monitoring
Performance Tuning
Troubleshooting
Reference Guide
Tool Guide
Data Type
Storage Engine
Execution Engine
Stream Processing
DR (Disaster Recovery)
Configuration Parameters
Index
Extension
SQL Reference
FAQ
Change the definition of a sequence generator.
ALTER SEQUENCE [ IF EXISTS ] name [INCREMENT [ BY ] increment]
[MINVALUE minvalue | NO MINVALUE]
[MAXVALUE maxvalue | NO MAXVALUE]
[START [ WITH ] start ]
[RESTART [ [ WITH ] restart] ]
[CACHE cache] [[ NO ] CYCLE]
[OWNED BY {table.column | NONE}]
ALTER SEQUENCE [ IF EXISTS ] name OWNER TO new_owner
ALTER SEQUENCE [ IF EXISTS ] name RENAME TO new_name
ALTER SEQUENCE [ IF EXISTS ] name SET SCHEMA new_schema
ALTER SEQUENCE Changes the parameters of an existing sequence generator. Any parameters that are not explicitly set in the ALTER SEQUENCE hit must maintain their previous settings.
The user must have this sequence to use ALTER SEQUENCE. To change the schema of a sequence, the user must also have CREATE privileges on the new schema. Note that superusers automatically have all privileges.
To change the owner, the user must be a direct or indirect member of the new role, and the new role must have CREATE permissions on the schema of the sequence (these restrictions force the change owner to not do anything that cannot be done by deleting and recreating the sequence. However, superusers can still change ownership of any sequence.)
name
IF EXISTS
Increment
minvalue
NO MINVALUE
maxvalue
NO MAXVALUE
start
restart
new_owner
cache
CYCLE
NO CYCLE
OWNED BY table.column
OWNED BY NONE
new_name
new_schema
To avoid blocking concurrent transactions that get numbers from the same sequence, the effect of ALTER SEQUENCE on sequence generation parameters is never rolled back. These changes will take effect immediately and are irreversible. However, the OWNED BY, OWNER TO, RENAME TO, and SET SCHEMA clauses are ordinary directory updates that can be rolled back.
ALTER SEQUENCE does not immediately affect nextval() results in sessions with preallocated (cache) sequence values except the current session. They will run out of all cached values before noticing the changed sequence generation parameters. The current session will be affected immediately.
ALTER TABLE can also be used with sequences for historical reasons. But the only variant of ALTER TABLE allowed by the sequence is equivalent to the above form.
Restart a sequence called serial at 105:
ALTER SEQUENCE serial RESTART WITH 105;
ALTER SEQUENCE complies with SQL standards, except for START WITH, OWNED BY, OWNER TO, RENAME TO, and SET SCHEMA clauses, which are extensions to the YMatrix database.