How set auto increment value start from a specific number and auto-increment increase by as specific value with offset

Step 1: How to set auto increment value start from a specific number.
For example:If we want to start auto-increment value from 5000 then use sql below.

mysql>> ALTER TABLE `smp_smps` AUTO_INCREMENT = 5000;

Note: We can set AUTO_INCREMENT value for any specific table.

Step 2: How to set auto increment value increase by as specific value.
For example: If we want auto-increment value increase by 3 per record then use sql below.

mysql>> SET @@GLOBAL.auto_increment_increment = 3;
Note: We can not set auto_increment_increment value for any specific table ,it affect on full database.

Step 3: How to set offset of auto increment key.
For example: If you set auto-increment value start from 5000 as in step 1 and now your requirement is the auto-increment value should start from 5001 in this situation you can use sql below.

mysql>> SET @@GLOBAL.auto_increment_offset = 1;

How set auto increment value start from a specific number and auto-increment increase by as specific value with offset How set auto increment value start from a specific number and auto-increment increase by as specific value with offset Reviewed by Web Technology Funda on 11:15:00 PM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!