How to change a Primary key to Auto_increment Constraint

Asked

Viewed 99 times

0

I 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 I added a PK

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

My difficulty how to make her now auto_increment

First attempt:

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

help!

1 answer

0

Hello,

ALTER TABLE `banco`.`tabela` 
MODIFY COLUMN `id` int(11) NOT NULL AUTO_INCREMENT FIRST;
  • banco.tabela have to set the name of the bank?

Browser other questions tagged

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