Syntax\n------\n\nCREATE [OR REPLACE] [TEMPORARY] SEQUENCE [IF NOT 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 ] \n[ CACHE [=] number | NOCACHE ] [ CYCLE | NOCYCLE] \ntable_options\n\nDescription\n-----------\n\nCREATE SEQUENCE creates a sequence that generates new values when called with NEXT VALUE FOR sequence_name. It's an alternative to AUTO INCREMENT if you want to have more control of how the numbers are generated. As the SEQUENCE caches values (up to CACHE), it can in some cases be much faster than AUTO INCREMENT. Another benefit is that you can access the last value generated by all used sequences, which solves one of the limitations with LAST_INSERT_ID().\n\nCREATE SEQUENCE requires the CREATE privilege.\n\nDROP SEQUENCE can be used to drop a sequence, and ALTER SEQUENCE to change it.\n\nCREATE Options\n\nAS\n\nINT type, that is, one of TINYINT, SMALLINT, MEDIUMINT, INT, INTEGER, BIGINT. Can be signed or unsigned. Maximum value is based on the data type. The use of BIGINT UNSIGNED with this option extends the possible maximum value from 9223372036854775806 to 18446744073709551614. Default is BIGINT.\n\nThe AS option is not available.\n\nINCREMENT\n\nIncrement to use for values. May be negative. Setting an increment of 0 causes the sequence to use the value of the auto_increment_increment system variable at the time of creation, which is always a positive number. (see MDEV-16035). Default 1.\n\nMINVALUE\n\nMinimum value for the sequence. From MariaDB 11.5, the parser permits much smaller numbers, such as -9999999999999999999999999999, but converts to the minimum permitted for the INT type, with a note. Default 1 if INCREMENT > 0 , and -9223372036854775807 (or based on int type) if INCREMENT < 0.\n\nMAXVALUE\n\nMaximum value for sequence. From MariaDB 11.5, the parser permits much larger numbers, such as 9999999999999999999999999999 used in Oracle examples, but converts to the maximum permitted for the INT type, with a note. Default 9223372036854775806 (or based on int type) if INCREMENT > 0 , and -1 if INCREMENT < 0.\n\nSTART\n\nFirst value the sequence will generate. Default MINVALUE if INCREMENT > 0, and MAX_VALUE if INCREMENT< 0.\n\nCACHE / NOCACHE\n\nNumber 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. Default 1000. FLUSH TABLES, shutting down the server, etc. will discard the cached values, and the next sequence number generated will be according to what's stored in the Sequence object. In effect, this will discard the cached values.\n\nNote that setting the cache to 1 from 1000 can make inserts to tables using sequences for default values 2x slower and increase the binary log sizes up to 7x.\n\nCYCLE / NOCYCLE\n\nIf CYCLE is used, then the sequence should start again from MINVALUE after it has run out of values. Default value is NOCYCLE.\n\nConstraints on Create Arguments\n\nTo be able to create a legal sequence, the following must hold:\n\n MAXVALUE >= start\n MAXVALUE > MINVALUE\n START >= MINVALUE\n MAXVALUE <= 9223372036854775806 (LONGLONG_MAX-1). From MariaDB 11.5, the parser accepts values beyond this, and converts based on the int type.\n* MINVALUE >= -9223372036854775807 (LONGLONG_MIN+1). From MariaDB 11.5, the parser accepts values beyond this, and converts based on the int type.\n\nNote that sequences can't generate the maximum/minimum 64 bit number because of the constraint ofMINVALUE and MAXVALUE.\n\nAtomic DDL\n\nMariaDB supports Atomic DDL and CREATE SEQUENCE is atomic.\n\nMariaDB does not support Atomic DDL and CREATE SEQUENCE is atomic.\n\nExamples\n--------\n\nCREATE SEQUENCE s START WITH 100 INCREMENT BY 10;\n\nCREATE SEQUENCE s2 START WITH -100 INCREMENT BY -10;\n\nURL: https://mariadb.com/docs/server/reference/sql-structure/sequences/create-sequence