Forum Moderators: coopster
Addited: You can also use functions in SQL Server -- these may be available in MySQL as well.
And of course, you could just write code to do it all for you. One thing I've done is use a "random key" generator to plug unique values in and have also used a 64bit guid.
If you follow this method, and are wanting, say, a unique numbered list, you could write a quick function that generates a random 3 byte string and then append that to your number (IE: 1-ie3, 2-dss, 3-g34, etc). That way you could still use an "order by" statement and the odds of having the same unique data left of the dash *and* after the dash is very remote.
In SQL Server, you can create multiple keys with unique constraints -- might check to see if you can do that in MySQL.
Certainly. It's an SQL standard. Give the column a UNIQUE [dev.mysql.com] constraint.
A UNIQUE constraint defines that particular column as unique and it is satisfied if no two rows in the table have the same non-null values in the UNIQUE column.
The more I read about MySQL, the more I wonder why I'm paying so much for so many SQL Servers LOL.
My biggest fear is how well it could handle our load -- how big of a machine would I need to process 60 million queries a day with MySQL? (we have multiple sites doing that many queries)
Thanks
S
I'm not sure I would dare specify unique on a partial index of text field, though, since what if the first 255 characters are not unique because many entries start with the same boilerplate text? You could get false positives that would prevent data entry for perfectly valid data.
Without knowing more about what you're trying to do, it's hard to give too much advice, but I would want to find unique records using criteria other than the text field if possible.
What data are you storing in there?