Brad Tilley wrote:
Hello again,

How do you make a field unique, but not have it as part of the primary key? For example, I have a 'computers' table that has a 'comp_id' field that's the primary key. It's an int that's auto-incremented with each new entry. The same table has a 'comp_serial' field. I want this field to be unique, but I don't want it to be a part of the primary key, or any key for that matter. I just want it to be unique. How do I achieve this?

Thanks,
Brad

ALTER TABLE computers ADD UNIQUE INDEX (comp_serial);


The index on comp_serial will enforce uniqueness, and it's separate from the primary key. I don't know of any way to enforce uniqueness without making a unique key on the column.

Michael


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to