How to make SQL Table Column data UNIQUE

I created this Clubs table in my SQL database but I want to make name row unique such that two rows will not have the same name.
CREATE TABLE clubs (
`id` integer PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`league` VARCHAR(45) NOT NULL,
`isActive` BOOLEAN,
created TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE TABLE clubs (
`id` integer PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`league` VARCHAR(45) NOT NULL,
`isActive` BOOLEAN,
created TIMESTAMP NOT NULL DEFAULT NOW()
);
4 Replies
StefanH
StefanH2y ago
Add UNIQUE to the column definition
Leke
LekeOP2y ago
Thanks
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Leke
LekeOP2y ago
Thanks, the documentation is really helpful
Want results from more Discord servers?
Add your server