Sql Server - Index on nvarchar field

前端 未结 3 1352
暗喜
暗喜 2021-02-07 11:25

What is the good approach to keep a nvarchar field unique. I have a field which is storing URLs of MP3 files. The URL length can be anything from 10 characters to 4

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-07 12:24

    You could create a hash code of the url and use this integer as a unique index on your db. Beware of converting all characters to lowercase first to ensure that all url are in the same format. Same url will generate equal hash code.

提交回复
热议问题