I created a user database in MySQL, the id is the primary key and I also want telephone number and country as a Unique key constraint:
CREATE TABLE IF NOT EXISTS `users` (
`id` int(16) NOT NULL AUTO_INCREMENT,
`phone` int(16) DEFAULT NULL,
`country` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UNIQUE_CONSTRAINTS` (`phone`,`country`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
You can also do iti\n PHPMyAdmin:
1) Click Structure in PHPMyADmin,
2) at bottom, click Relation view, first you need to create index,
3) at bottom, click +Indexes
4) After you create index, the dropdown menu will show under Foreign key Constraint (INNODB).
5) After you select table and column,
constraint name, ON DELETE and ON UPDATE inputs will show up.
No comments:
Post a Comment