I am storing URLs in a column having varchar(4000) data type. I want to enforce uniqueness constraint on this column but not able to do so because 4000 is way beyond max limit.
Is there any way to enforce uniqueness on such columns ?
I am storing URLs in a column having varchar(4000) data type. I want to enforce uniqueness constraint on this column but not able to do so because 4000 is way beyond max limit.
Is there any way to enforce uniqueness on such columns ?
The uniqueness of that long fields is not enforcable by use of indices.
The right way is likely to perform a select inside a trigger before insert/update and failing for a value that is already contained in the column.
A practicable workaround at the application level or inside a stored procedure may be to perform a select for the new value followed by an insert (if that value is not already present) inside a transaction.
In any case, part of the column in question shoud be (non-uniquely) indexed to speed the select.