in MySQL, how to I work around it not being able to use defined strings as an index?
Thinking the approach would be to create a hash of the string at a fixed开发者_Python百科 length and then index the hash. If so, is there a way to do this within MySQL, or does it require me to do some parts of the process outside of MySQL.
Database engine is InnoDB and here's info on the error I'm getting that appears to be on target.
http://forums.techarena.in/software-development/1185285.htm
Basically trying to use a column that is a natural longtext key as a UNIQUE constraint, meaning that an insert transaction is rolled back if the column field is not unique. The column can be 80 to 150 thousand characters in length.
Generally UNIQUE
indexes on TEXT/LONGTEXT/BLOB
fields are not a good idea as MySQL is not capable of having an arbitrary length index. You either have to specify a maximum number of characters (eg. UNIQUE (fieldname(255))
- I believe 4005 is the current limit for UTF8, 1000 regular), limiting the field length (in which case you might as well make it a VARCHAR
), or remove the UNIQUE
index.
精彩评论