Hello, I have a table: CREATE TABLE types ( id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , info VARCHAR(128) NOT NULL , name VARCHAR(32) NOT NULL , PRIMARY KEY (id) , UNIQUE INDEX (info, name) ) ENGINE=InnoDB CHARACTER SET latin1 COLLATE latin1_swedish_ci; Code (SQL): If I want to have an unique index, should I add the following code? CREATE UNIQUE INDEX types_unique_index ON types (info, name); Code (SQL):
WHY do you need that unique index? You have an auto-increment primary key field - that will be unique, so why do you need the separate, unique index?
Yes, I understand that, but explaining what you want to do, instead of asking "should I do this" usually leads to better answers. Because most times, people asking "should I do this" are on the wrong track to begin with. You should read up on this: What is the XY problem
I just do not know if... UNIQUE INDEX (info, name) Code (SQL): ...does the same job as the following code: CREATE UNIQUE INDEX types_unique_index ON types (info, name); Code (SQL):
They are functionally the same, yes, except the latter one has an arbitrary name for the unique multiple index.