sequences_in_mariadb.txt (543B)
Q: What is the purpose of a sequence in MariaDB? A: A sequence is a database object that generates a series of unique, ordered numeric values kind of like a counter managed by the database, separate from any table. It is independent of tables, the same sequence can be shared between multiple tables if needed. Can customize start value, increment, min/max and whether it cycles. CREATE SEQUENCE invoice_seq START WITH 1000 INCREMENT BY 1; INSERT INTO invoices (id, customer, amount) VALUES (NEXT VALUE FOR invoice_seq, 'Alice', 500);