database - Mysql Unique record 2 columns -
i making application inserts users mysql database.
i know can make column value unique, want combination of 2 columns in record unique.
for example:
id firstname lastname creationdate ----------------------------------------- 1 john doe (today)
what want achieve can enter record :
2, john, deo, (today)
but cannot enter:
2, john, doe, (today)
what sql statement can use make combination of multiple columns unique?
use below query
alter table persons add constraint pk_personid primary key (firstname,lastname)
Comments
Post a Comment