1
I am proceeding this way to create a table without primary key initially. Then I add a field id
serial type and try to create the Constraint to the Primary Key (PK):
create table macaco(
nome varchar(50),
idade integer
);
--adicionando o id do tipo serial
ALTER TABLE "macaco" ADD COLUMN id SERIAL;
--criando a primary key
ALTER TABLE "macaco" ADD PRIMARY KEY (id);
The way I do above, it creates the PK with the name of macaco_pkey
.
So far so good. But what if I want to create the Constraint with the name id_macaco_pk
, what should I do?
All right, man, you helped a lot!
– Pena Pintada