Query the type and value of a sequence
Query a sequence
Syntax
SHOW SEQUENCES
ExamplesExecute the following statement in your CLI:
mysql> SHOW SEQUENCES;
The following query result is returned:
+------+--------+------------+------------+------------+--------------+------------+-------------+-------+--------+
| NAME | VALUE | UNIT_COUNT | UNIT_INDEX | INNER_STEP | INCREMENT_BY | START_WITH | MAX_VALUE | CYCLE | TYPE |
+------+--------+------------+------------+------------+--------------+------------+-------------+-------+--------+
| seq1 | 100000 | 1 | 0 | 100000 | N/A | N/A | N/A | N/A | GROUP |
| seq2 | 400000 | 3 | 1 | 100000 | N/A | N/A | N/A | N/A | GROUP |
| seq3 | N/A | N/A | N/A | N/A | N/A | N/A | N/A | N/A | TIME |
| seq4 | 1006 | N/A | N/A | N/A | 2 | 1000 | 99999999999 | N | SIMPLE |
+------+--------+------------+------------+------------+--------------+------------+-------------+-------+--------+
4 rows in set (0.00 sec)
Note In the query result, the values in the TYPE column are the abbreviations of the sequence types.
Query a sequence
Syntax
[<schema_name>.]<sequence name>.NEXTVAL
Examples
Method 1
mysql> SELECT sample_seq.nextval FROM dual;
The following query result is returned:
```plaintext
+--------------------+
| SAMPLE_SEQ.NEXTVAL |
+--------------------+
| 101001 |
+--------------------+
1 row in set (0.04 sec)
```
Method 2: Execute the following statement in your CLI:
mysql> INSERT INTO some_users (name,address,gmt_create,gmt_modified,intro) VALUES ('sun',sample_seq.nextval,now(),now(),'aa');
**Note**
* When you use this statement, you include sample_seq.nextval in the SQL statement as a value.
* If the AUTO_INCREMENT parameter is specified when you create a table, you do not need to specify an auto-increment column when you execute the INSERT statement. PolarDB-X 1.0 automatically manage the value of the AUTO_INCREMENT parameter.
Use the following syntax to query multiple sequence values at a time:
Syntax: The following code provides the syntax:
SELECT [<schema_name>.]<sequence name>.NEXTVAL FROM DUAL WHERE COUNT = <numeric value>
Examples: Execute the following statement in your CLI:
mysql> SELECT sample_seq.nextval FROM dual WHERE count = 10;
The following query result is returned:
+--------------------+
| SAMPLE_SEQ.NEXTVAL |
+--------------------+
| 101002 |
| 101003 |
| 101004 |
| 101005 |
| 101006 |
| 101007 |
| 101008 |
| 101009 |
| 101010 |
| 101011 |
+--------------------+
10 row in set (0.04 sec)