Mysql auto_increment of 2 in 2 (2, 4, 6...)

Asked

Viewed 65 times

1

How do SQL auto_increment to increment the number from 2 to 2 (2, 4, 6...) in an identifier field?

create table cliente (
    idcliente int not null auto_increment,
    nome varchar(40) not null,
    cpf char(11) unique not null,
    nascimento date not null,
    sexo enum('F','M') not null,
    email varchar(40) unique not null,
    nacionalidade varchar(10) default 'Brasil',
    primary key (idcliente)
) default charset = utf8;
  • 3

    https://stackoverflow.com/questions/1686327/change-the-step-auto-increment-fields-increment-by

  • 3

    You have to edit your my.cnf and configure auto_increment_increment = 2 or on the command line configure the variable using set this way: SET @@auto_increment_increment=2; Reply given in comment because @Motta had already pointed out a post that explains the functionality.

  • @Motts, Raphael Solomon. It would be nice if one of you (or both) would post an answer so that I can vote positively :).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.