Skip to content

Instantly share code, notes, and snippets.

@Kichrum
Created August 13, 2014 09:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kichrum/301815bda8b5958a3f00 to your computer and use it in GitHub Desktop.
Save Kichrum/301815bda8b5958a3f00 to your computer and use it in GitHub Desktop.
AUTO_INCREMENT: getter and setter
-- Get AUTO_INCREMENT current value:
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'DatabaseName'
AND TABLE_NAME = 'TableName';
-- SET AUTO_INCREMENT value (this number will be user for NEXT inserted element):
ALTER TABLE `TableName` AUTO_INCREMENT = 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment