Skip to content

Instantly share code, notes, and snippets.

@justdoit0823
Last active October 27, 2018 07:25
Show Gist options
  • Save justdoit0823/110f3c2b98ebbe9d072fd3f7e3c0dbc8 to your computer and use it in GitHub Desktop.
Save justdoit0823/110f3c2b98ebbe9d072fd3f7e3c0dbc8 to your computer and use it in GitHub Desktop.
mysql auto increment.
drop table if exists s_test_mysql_auto_increment;
create table s_test_mysql_auto_increment(id int primary key auto_increment, value int);
insert into s_test_mysql_auto_increment(value) values (10000);
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 's_test_mysql_auto_increment';
insert into s_test_mysql_auto_increment(value) values (10001);
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 's_test_mysql_auto_increment';
insert into s_test_mysql_auto_increment(value) values (10002);
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 's_test_mysql_auto_increment';
insert into s_test_mysql_auto_increment(id, value) values (1000, 10002);
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 's_test_mysql_auto_increment';
insert into s_test_mysql_auto_increment(id, value) values (500, 10002);
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 's_test_mysql_auto_increment';
insert into s_test_mysql_auto_increment(value) values (10002);
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 's_test_mysql_auto_increment';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment