tags:

views:

97

answers:

2

Sorry for newbie question - am I understand right that these two operators are identical in Mysql?

ALTER TABLE friends ADD CONSTRAINT UNIQUE (`user_id`, `friend_id`);

and

CREATE UNIQUE INDEX friends_user_friend ON friends (user_id, friend_id);
+2  A: 

yes !

only CREATE INDEX cannot be used to create a PRIMARY KEY, use ALTER TABLE instead

read more in :

http://dev.mysql.com/doc/refman/5.0/en/create-index.html

Haim Evgi