On Fri, 2 Mar 2001, Nick Kostirya wrote:
> Hi, All!
>
> Please, give me an opinion about multiple-column index.
> May I create the UNIQUE multiple-column index, which the index of each
> column is not UNIQUE in?
> If yes than how do it?
>
> Best.
> Nick.
When you create a multi-column unique index, it means that the combination of the
participating columns must be "unique" and not that each of the participating columns
must be "unique" by itself.
How you do it?...the normal way:
mysql> create unique my_index on my_table (col1,col2..);
and you may or may not have indeces (unique or not) on cols 1,2...
The above is fully equivalent (as of 3.22) to:
mysql> alter table my_table add unique my_index (col1,col2...);
But be careful because even though Mysql will complain if you try to insert a tuple
whose value for the unique index attributes (col1,2...) is the same as an already
existing tuple, this doesn't hold if any of the index attributes is NULL. To cut a
long story short (as I understand it): NULL!=NULL
regards,
thalis
-
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php