Is it possible to have auto increment field which generates even or odd numbers (skips the opposite)? The reason I am asking is because I want to share auto increment between two tables. Other ways for achieving it are welcomed.
Thanks in advance!
As mentioned by Juergen you could do that at system level instead of session level by making following change (or adding) in my.ini file:
auto-increment-increment = 2
auto-increment-offset = 1
or
auto-increment-increment = 2
auto-increment-offset = 2
Basically this is much used in Master-Master replication setup.
try
SET @@auto_increment_increment=2;
SET @@auto_increment_offset=2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With