W3cubDocs

/MariaDB

SHOW CREATE SEQUENCE

MariaDB starting with 10.3.1

Sequences were introduced in MariaDB 10.3.

Syntax

SHOW CREATE SEQUENCE sequence_name;

Description

Shows the CREATE SEQUENCE statement that created the given sequence. The statement requires the SELECT privilege for the table.

Example

CREATE SEQUENCE s1 START WITH 50;
SHOW CREATE SEQUENCE s1\G;

*************************** 1. row ***************************
       Table: t1
Create Table: CREATE SEQUENCE `s1` start with 50 minvalue 1 maxvalue 9223372036854775806
increment by 1 cache 1000 nocycle ENGINE=Aria

Notes

If you want to see the underlying table structure used for the SEQUENCE you can use SHOW CREATE TABLE on the SEQUENCE. You can also use SELECT to read the current recorded state of the SEQUENCE:

CREATE SEQUENCE t1;
SHOW CREATE TABLE s1\G
*************************** 1. row ***************************
       Table: s1
Create Table: CREATE TABLE `s1` (
  `next_value` bigint(21) NOT NULL COMMENT 'next not cached value',
  `min_value` bigint(21) NOT NULL COMMENT 'min value',
  `max_value` bigint(21) NOT NULL COMMENT 'max value',
  `start` bigint(21) NOT NULL COMMENT 'start value',
  `increment` bigint(21) NOT NULL COMMENT 'increment value',
  `cache` bigint(21) NOT NULL COMMENT 'cache size',
  `cycle` tinyint(1) unsigned NOT NULL COMMENT 'cycle state',
  `round` bigint(21) NOT NULL COMMENT 'How many cycles has been done'
) ENGINE=Aria SEQUENCE=1

SELECT * FROM s1;
+------------+-----------+---------------------+-------+-----------+-------+-------+-------+
| next_value | min_value | max_value           | start | increment | cache | cycle | round |
+------------+-----------+---------------------+-------+-----------+-------+-------+-------+
|          1 |         1 | 9223372036854775806 |     1 |         1 |  1000 |     0 |     0 |
+------------+-----------+---------------------+-------+-----------+-------+-------+-------+

See Also

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.

© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/show-create-sequence/