How to change a primary key for constraint Auto_increment

0

I've created the following table

create table if not exists cursos(
nome varchar (30) not null unique,
descicao text,
carga int unsigned,
totaulas int,
ano year default '2018'

)default charset = utf8;

After adding a PK

alter table cursos
add primary key (idCurso);
alter table cursos add column idCurso varchar(10) after nome;

My difficulty how to make it now auto_increment

First attempt:

 alter table cursos add constraint idCursos varchar(10)  auto_increment;

help!

    
asked by anonymous 28.11.2018 / 13:46

1 answer

0

Hello,

ALTER TABLE 'banco'.'tabela' 
MODIFY COLUMN 'id' int(11) NOT NULL AUTO_INCREMENT FIRST;
    
28.11.2018 / 13:52