How to add a unique constraint on a column without deleting the table or column

0

This is the sample table

create table usuario(
    id serial primary key not null,
    nome varchar(100),
    email varchar(100),
    login varchar(100),
    senha varchar(100),
    tipo varchar(50),
    status varchar(30)
)

I used this code, but it did not work

alter table usuario add constraint unique_login unique(login)
    
asked by anonymous 01.03.2018 / 03:43

2 answers

0

Hello. I tried it and it worked:

alter table usuario add unique(login);
    
02.03.2018 / 14:43
0

the codes

alter table usuario add constraint unique_login unique(login)

and

alter table usuario add unique(login)

are correct. I tested the two and both work

    
03.03.2018 / 18:23