Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making values of two columns Unique

Status
Not open for further replies.

Delphard

Programmer
Jul 22, 2004
144
RS
1. Two columns, one is CHAR type, second is INTEGER. None of them is Unique, but combination of them must be. How to make this in MySQL 4.1.10?
2. What kind of Index (INDEX, UNIQUE INDEX,...) I should make on this columns to get better performance?
Thanks in advance!
 
make both columns primary keys. That should do exactly what you are looking for. As for the index, the regular one should be fine
 
if you make the pair of columns the primary key, then you do not need to declare any other index (unless you want to access the 2nd column separately, in which case a separate index on the 2nd column alone might be useful)

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts May 8 2005)
 
I forgot to say: I already have column that acts as PrimaryKey (ID). I just need that combination of values in these other two columns must be Unique. Is there other approach, without making PrimaryKey on these two columns?
 
ID must remain as PrimaryKey, because it's used in many Tables as ForeignKey and in Queries as Parameter.
Any other way?
 
I try this before your reply and find it works!
Thanks anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top