Alarm Upgrade
tdsql_, and the proxy version must be later than 1.19.5-M-V2.0R745D005. You can view the proxy version by running the /*Proxy*/show status statement. If the proxy is on an earlier version, you can submit a ticket for upgrade.CREATE SEQUENCE system permission. The creation syntax is as follows:CREATE TDSQL_SEQUENCE sequence name[START WITH n][{TDSQL_MINVALUE/ TDSQL_MAXMINVALUE n| TDSQL_NOMAXVALUE}][TDSQL_INCREMENT BY n][{TDSQL_CYCLE|TDSQL_NOCYCLE}]
create tdsql_sequence test.s1 start with 12 tdsql_minvalue 10 maxvalue 50000 tdsql_increment by 5 tdsql_nocycle;create tdsql_sequence test.s2 start with 12 tdsql_minvalue 10 maxvalue 50000 tdsql_increment by 1 tdsql_cycle;
drop tdsql_sequence test.s1;
select tdsql_nextval(test.s2);select next value for test.s2;
mysql> select tdsql_nextval(test.s1);+----+| 12 |+----+| 12 |+----+1 row in set (0.18 sec)mysql> select tdsql_nextval(test.s2);+----+| 12 |+----+| 12 |+----+1 row in set (0.13 sec)mysql> select tdsql_nextval(test.s1);+----+| 17 |+----+| 17 |+----+1 row in set (0.01 sec)mysql> select tdsql_nextval(test.s2);+----+| 13 |+----+| 13 |+----+1 row in set (0.00 sec)mysql> select next value for test.s1;+----+| 22 |+----+| 22 |+----+1 row in set (0.01 sec)
mysql> select * from test.t1;+----+------+| a | b |+----+------+| 11 | 2 |+----+------+1 row in set (0.00 sec)mysql> insert into test.t1(a,b) values(tdsql_nextval(test.s2),3);Query OK, 1 row affected (0.01 sec)mysql> select * from test.t1;+----+------+| a | b |+----+------+| 11 | 2 || 14 | 3 |+----+------+2 rows in set (0.00 sec)
nextval command, 0 will be returned.select tdsql_lastval(test.s1);select tdsql_previous value for test.s1;
mysql> select tdsql_lastval(test.s1);+----+| 22 |+----+| 22 |+----+1 row in set (0.00 sec)mysql> select tdsql_previous value for test.s1;+----+| 22 |+----+| 22 |+----+1 row in set (0.00 sec)
select tdsql_setval(test.s2,1000,bool use) // `use` is 1 by default, indicating that the value of 1,000 has been used and will not be included next time. If this is 0, the next return will start from 1,000.
mysql> select tdsql_nextval(test.s2);+----+| 15 |+----+| 15 |+----+1 row in set (0.01 sec)mysql> select tdsql_setval(test.s2,10);+---+| 0 |+---+| 0 |+---+1 row in set (0.03 sec)mysql> select tdsql_nextval(test.s2);+----+| 16 |+----+| 16 |+----+
mysql> select tdsql_setval(test.s2,20);+----+| 20 |+----+| 20 |+----+1 row in set (0.02 sec)mysql> select tdsql_nextval(test.s2);+----+| 21 |+----+| 21 |+----+1 row in set (0.01 sec)
select tdsql_resetval(test.s2,1000);
mysql> select tdsql_resetval(test.s2,14);+----+| 14 |+----+| 14 |+----+1 row in set (0.00 sec)mysql> select tdsql_nextval(test.s2);+----+| 14 |+----+| 14 |+----+1 row in set (0.01 sec)
TDSQL_:oldstyle configuration item is enabled, the proxy will be compatible with the standard Sequence keyword; that is, the TDSQL_ prefix can be omitted for the keyword.TDSQL_CYCLETDSQL_INCREMENTTDSQL_LASTVALTDSQL_MINVALUETDSQL_NEXTVALTDSQL_NOCACHETDSQL_NOCYCLETDSQL_NOMAXVALUETDSQL_NOMINVALUETDSQL_PREVIOUSTDSQL_RESTARTTDSQL_REUSETDSQL_SEQUENCETDSQL_SETVAL
フィードバック