diff --git a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence.md b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence.md index 8fdbf0cb5..a57a44472 100644 --- a/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence.md +++ b/docs/MatrixOne/Reference/SQL-Reference/Data-Definition-Language/1.1-alter-sequence.md @@ -38,47 +38,82 @@ -- Create a sequence named alter_seq_01 with an increment of 2, a minimum value of 30, a maximum value of 100, and enable cycling create sequence alter_seq_01 as smallint increment by 2 minvalue 30 maxvalue 100 cycle; -mysql> select * from alter_seq_01; -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ -| last_seq_num | min_value | max_value | start_value | increment_value | cycle | is_called | -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ -| 30 | 30 | 100 | 30 | 2 | true | false | -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ +mysql> show sequences; ++--------------+-----------+ +| Names | Data Type | ++--------------+-----------+ +| alter_seq_01 | SMALLINT | ++--------------+-----------+ +1 row in set (0.00 sec) + +mysql> alter sequence alter_seq_01 as bigint; +Query OK, 0 rows affected (0.01 sec) + +mysql> show sequences; ++--------------+-----------+ +| Names | Data Type | ++--------------+-----------+ +| alter_seq_01 | BIGINT | ++--------------+-----------+ 1 row in set (0.00 sec) -- Remove cycling for sequence alter_seq_01 mysql> alter sequence alter_seq_01 no cycle; Query OK, 0 rows affected (0.01 sec) -mysql> select * from alter_seq_01; -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ -| last_seq_num | min_value | max_value | start_value | increment_value | cycle | is_called | -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ -| 30 | 30 | 100 | 30 | 2 | false | false | -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ +mysql> select nextval('alter_seq_01'),currval('alter_seq_01'); ++-----------------------+-----------------------+ +| nextval(alter_seq_01) | currval(alter_seq_01) | ++-----------------------+-----------------------+ +| 30 | 30 | ++-----------------------+-----------------------+ +1 row in set (0.01 sec) + +mysql> select nextval('alter_seq_01'),currval('alter_seq_01'); ++-----------------------+-----------------------+ +| nextval(alter_seq_01) | currval(alter_seq_01) | ++-----------------------+-----------------------+ +| 32 | 32 | ++-----------------------+-----------------------+ 1 row in set (0.00 sec) -- Set the starting value of sequence alter_seq_01 to 40 mysql> alter sequence alter_seq_01 start with 40; Query OK, 0 rows affected (0.01 sec) -mysql> select * from alter_seq_01; -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ -| last_seq_num | min_value | max_value | start_value | increment_value | cycle | is_called | -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ -| 40 | 30 | 100 | 40 | 3 | false | false | -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ +mysql> select nextval('alter_seq_01'),currval('alter_seq_01'); ++-----------------------+-----------------------+ +| nextval(alter_seq_01) | currval(alter_seq_01) | ++-----------------------+-----------------------+ +| 40 | 40 | ++-----------------------+-----------------------+ 1 row in set (0.01 sec) +mysql> select nextval('alter_seq_01'),currval('alter_seq_01'); ++-----------------------+-----------------------+ +| nextval(alter_seq_01) | currval(alter_seq_01) | ++-----------------------+-----------------------+ +| 42 | 42 | ++-----------------------+-----------------------+ +1 row in set (0.00 sec) + -- Set the increment value of sequence alter_seq_01 to 3 mysql> alter sequence alter_seq_01 increment by 3; Query OK, 0 rows affected (0.01 sec) -mysql> select * from alter_seq_01; -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ -| last_seq_num | min_value | max_value | start_value | increment_value | cycle | is_called | -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ -| 40 | 30 | 100 | 40 | 3 | false | false | -+--------------+-----------+-----------+-------------+-----------------+-------+-----------+ +mysql> select nextval('alter_seq_01'),currval('alter_seq_01'); ++-----------------------+-----------------------+ +| nextval(alter_seq_01) | currval(alter_seq_01) | ++-----------------------+-----------------------+ +| 40 | 40 | ++-----------------------+-----------------------+ +1 row in set (0.00 sec) + +mysql> select nextval('alter_seq_01'),currval('alter_seq_01'); ++-----------------------+-----------------------+ +| nextval(alter_seq_01) | currval(alter_seq_01) | ++-----------------------+-----------------------+ +| 43 | 43 | ++-----------------------+-----------------------+ 1 row in set (0.00 sec) ```