Jump to content


Photo

question on index types


  • Please log in to reply
1 reply to this topic

#1 jworisek

jworisek
  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 04 April 2006 - 07:16 PM

Just curious about index types (haven't found quite what I was looking for in the manual, but maybe Im just searching the wrong key words). What exactly are the differences between Primary, Unique, and Index?

As I understand it:

Primary: only unique entries for specified columns are allowed and null values aren't allowed.

Unique: only unique entries for specified columns are allowed and null values are allowed.

Index: doesn't require uniqueness?

but in joining tables all work in the same sense correct?

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 04 April 2006 - 11:11 PM

Yes, they all speed up your queries. You can only have one primary key per table (hence "primary"). You can have as many UNIQUEs as you want.

With both PRIMARY and UNIQUE, your INSERTs will fail if you try to insert a row that would break the uniqueness of the indexed column. In exchange, you can be confident that your data is consistent and those columns are never duplicated.

Normal INDEXes just give you the speed boost without demanding uniqueness. You can have as many as you want (although they eat up space).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users