MySQL Forums
Forum List  »  Newbie

Re: Question related to unique key
Posted by: Rick James
Date: March 16, 2009 10:48PM

Think of a PRIMARY KEY as the preferred way to unambiguously identify each row in the table. Ok, maybe you could envision a row as being identified by 'null', but why bother.

Another note: KEY is the same as INDEX. Neither implies uniqueness.

A common PRIMARY KEY is
INT UNSIGNED AUTO_INCREMENT NOT NULL
This assigns a number (1,2,...) to each row (assuming you don't explicitly set it).

An INSERT will spit at you if you violate a UNIQUEness constraint.

MyISAM does not require any keys.
InnoDB requires a PRIMARY KEY, even to the point of providing one if you don't specify one.

Options: ReplyQuote


Subject
Written By
Posted
March 16, 2009 07:43AM
Re: Question related to unique key
March 16, 2009 10:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.