mysql unique two columns 1

mysql unique two columns

CREATE TABLE `content_html` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_box_elements` int(11) DEFAULT NULL,
  `id_router` int(11) DEFAULT NULL,
  `content` mediumtext COLLATE utf8_czech_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_box_elements` (`id_box_elements`,`id_router`)
);

Here is what the above code is Doing:
1. Create a table called content_html
2. Create a column called id and set it to auto increment
3. Create a column called id_box_elements and set it to int(11) and set it to null
4. Create a column called id_router and set it to int(11) and set it to null
5. Create a column called content and set it to mediumtext and set it to utf8_czech_ci and set it to not null
6. Set the id column to primary key
7. Set the id_box_elements and id_router columns to unique key

Similar Posts