Syntax\n------\n\nSETVAL(sequence_name, next_value, [is_used, [round]])\n\nDescription\n-----------\n\nSet the next value to be returned for a SEQUENCE.\n\nThis function is compatible with PostgreSQL syntax, extended with the round argument.\n\nIf the is_used argument is not given or is 1 or true, then the next used value will one after the given value. If is_used is 0 or false then the next generated value will be the given value.\n\nIf round is used then it will set the round value (or the internal cycle count, starting at zero) for the sequence. If round is not used, it's assumed to be 0.\n\nnext_value must be an integer literal.\n\nFor SEQUENCE tables defined with CYCLE (see CREATE SEQUENCE) one should use both next_value and round to define the next value. In this case the current sequence value is defined to be round, next_value.\n\nThe result returned by SETVAL() is next_value or NULL if the given next_value and round is smaller than the current value.\n\nSETVAL() will not set the SEQUENCE value to a something that is less than its current value. This is needed to ensure that SETVAL() is replication-safe. If you want to set the SEQUENCE to a smaller number, use ALTER SEQUENCE.\n\nIf CYCLE is used, first round and then next_value are compared to see if the value is bigger than the current value.\n\nInternally, in the MariaDB server, SETVAL() is used to inform slaves that a SEQUENCE has changed value. The slave may getSETVAL() statements out of order, but this is ok as only the biggest one will have an effect.\n\nSETVAL requires the INSERT privilege.\n\nExamples\n--------\n\nSELECT setval(foo, 42);           -- Next nextval will return 43\nSELECT setval(foo, 42, TRUE);     -- Same as above\nSELECT setval(foo, 42, FALSE);    -- Next nextval will return 42\n\nURL: https://mariadb.com/docs/server/reference/sql-structure/sequences/sequence-functions/setval