Entry
Do you need a PRIMARY KEY or other way to specify a unique value in a MySQL row?
Mar 15th, 2004 10:28
Matt Chatterley, mike gifford,
In order that you can be guaranteed to uniquely identify a given ROW in
a table, you must assign a primary key to that row - this is both a
unique value used to identify the row (e.g. UserID in a 'users' table),
and an index for look-ups against this identification.
If you wanted to ensure a particular column was unique, you would need
to add a UNIQUE INDEX to the table:
ALTER TABLE Table1 ADD INDEX index_name UNIQUE (Unique_Column);