Syntax\n------\n\nALTER SEQUENCE [IF EXISTS] sequence_name\n[AS { TINYINT | SMALLINT | |MEDIUMINT | INT | INTEGER | BIGINT } [SIGNED | UNSIGNED]]\n[ INCREMENT [ BY | = ] number ]\n[ MINVALUE [=] number | NO MINVALUE | NOMINVALUE ]\n[ MAXVALUE [=] number | NO MAXVALUE | NOMAXVALUE ]\n[ START [ WITH | = ] number ] [ CACHE [=] number ] [ [ NO ] CYCLE ]\n[ RESTART [[WITH | =] number]\n\nDescription\n-----------\n\nALTER SEQUENCE changes the parameters of an existing sequence generator. Any parameters not specifically set in the ALTER SEQUENCE command retain their prior settings.\n\nALTER SEQUENCE requires the ALTER privilege.\n\nOptions to ALTER SEQUENCE\n\n| Option    | Default value                                                | Description                                                                                                                                                                 |\n| --------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| INCREMENT | 1                                                            | Increment to use for values. May be negative.                                                                                                                               |\n| MINVALUE  | 1 if INCREMENT > 0 and -9223372036854775807 if INCREMENT < 0 | Minimum value for the sequence.                                                                                                                                             |\n| MAXVALUE  | 9223372036854775806 if INCREMENT > 0 and -1 if INCREMENT < 0 | Max value for sequence.                                                                                                                                                     |\n| START     | MINVALUE if INCREMENT > 0 and MAX_VALUE if INCREMENT< 0     | First value that the sequence will generate.                                                                                                                                |\n| CACHE     | 1000                                                         | Number of values that should be cached. 0 if no CACHE. The underlying table will be updated first time a new sequence number is generated and each time the cache runs out. |\n| CYCLE     | 0 (= NO CYCLE)                                               | 1 if the sequence should start again from MINVALUE                                                                                                                          |\n\nThe optional clause RESTART [ WITH restart ] sets the next value for the sequence. This is equivalent to calling the SETVAL() function with the is_used argument as 0. The specified value will be returned by the next call of nextval. Using RESTART with no restart value is equivalent to supplying the start value that was recorded by CREATE SEQUENCE or last set by ALTER SEQUENCE START WITH.\n\nALTER SEQUENCE does not allow to change the sequence so that it's inconsistent:\n\n``sql\nCREATE SEQUENCE s1;\nALTER SEQUENCE s1 MINVALUE 10;\nERROR 4061 (HY000): Sequence 'test.t1' values are conflicting\n\nALTER SEQUENCE s1 MINVALUE 10 RESTART 10;\nERROR 4061 (HY000): Sequence 'test.t1' values are conflicting\n\nALTER SEQUENCE s1 MINVALUE 10 START 10 RESTART 10;\n`\n\nINSERT\n\nTo allow SEQUENCE objects to be backed up by old tools, like mariadb-dump, one can use SELECT to read the current state of a SEQUENCE object and use an INSERT to update the SEQUENCE object. INSERT is only allowed if all fields are specified:\n\n`sql\nCREATE SEQUENCE s1;\nINSERT INTO s1 VALUES(1000,10,2000,1005,1,1000,0,0);\nSELECT * FROM s1;\n\n+------------+-----------+-----------+-------+-----------+-------+-------+-------+\n| next_value | min_value | max_value | start | increment | cache | cycle | round |\n+------------+-----------+-----------+-------+-----------+-------+-------+-------+\n|       1000 |        10 |      2000 |  1005 |         1 |  1000 |     0 |     0 |\n+------------+-----------+-----------+-------+-----------+-------+-------+-------+\n\nSHOW CREATE SEQUENCE s1;\n+-------+--------------------------------------------------------------------------------------------------------------+\n| Table | Create Table                                                                                                 |\n+-------+--------------------------------------------------------------------------------------------------------------+\n| s1    | CREATE SEQUENCE s1 start with 1005 minvalue 10 maxvalue 2000 increment by 1 cache 1000 nocycle ENGINE=Aria |\n+-------+--------------------------------------------------------------------------------------------------------------+\n`\n\nNotes\n\nALTER SEQUENCE will instantly affect all future SEQUENCE operations. This is in contrast to some other databases where the changes requested by ALTER SEQUENCE will not be seen until the sequence cache has run out.\n\nALTER SEQUENCE will take a full table lock of the sequence object during its (brief) operation. This ensures that ALTER SEQUENCE` is replicated correctly. If you only want to set the next sequence value to a higher value than current, then you should use SETVAL() instead, as this is not blocking.\n\nIf you want to change the storage engine or sequence comment, or rename the sequence, you can use ALTER TABLE for this.\n\nURL: https://mariadb.com/docs/server/reference/sql-structure/sequences/alter-sequence