Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto increment by 1 in MySQL with clearDB

I am using Windows Azure with clearDB. Current database auto-increment value is 10. I want it as 1.

I tried to run these commands in PHPMyAdmin with,

1)

set global auto_increment_increment = 1;
set global auto_increment_offset = 1;

ERROR: #1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation

2)

set auto_increment_increment = 1;
set auto_increment_offset = 1;

After that I checked it by this command,

SHOW VARIABLES LIKE 'auto_inc%';

RESULT:

Variable_name                 Value     
auto_increment_increment      10
auto_increment_offset         1

What could be the reason?

like image 790
Ronak Patel Avatar asked Sep 23 '14 19:09

Ronak Patel


People also ask

Can we insert auto increment value in MySQL?

Syntax for MySQLMySQL uses the AUTO_INCREMENT keyword to perform an auto-increment feature. By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record. VALUES ('Lars','Monsen'); The SQL statement above would insert a new record into the "Persons" table.

Does auto increment work with varchar?

AutoIncrement fields are integer in mysql. You can mirror the auto-increment field in a varchar field and create a trigger which updates the varchar field on insert/update.

How can create auto increment column in MySQL query?

MySQL has the AUTO_INCREMENT keyword to perform auto-increment. The starting value for AUTO_INCREMENT is 1, which is the default. It will get increment by 1 for each new record. To get the next auto increment id in MySQL, we can use the function last_insert_id() from MySQL or auto_increment with SELECT.


1 Answers

When I submitted ticket to clearDB, They replied me like this:

ClearDB uses circular replication to provide master-master MySQL support. As such, certain things such as auto_increment keys (or sequences) must be configured in order for one master not to use the same key as the other, in all cases. We do this by configuring MySQL to skip certain keys, and by enforcing MySQL to use a specific offset for each key used. The reason why we use a value of 10 instead of 2 is for future development.

like image 167
Ronak Patel Avatar answered Oct 06 '22 01:10

Ronak Patel