is of a type that is invalid for use as a key column in an index

后端 未结 5 2015
我在风中等你
我在风中等你 2020-11-29 21:57

I have an error at

Column \'key\' in table \'misc_info\' is of a type that is invalid for use as a key column in an index.

where key is a n

5条回答
  •  被撕碎了的回忆
    2020-11-29 22:39

    Noting klaisbyskov's comment about your key length needing to be gigabytes in size, and assuming that you do in fact need this, then I think your only options are:

    1. use a hash of the key value
      • Create a column on nchar(40) (for a sha1 hash, for example),
      • put a unique key on the hash column.
      • generate the hash when saving or updating the record
    2. triggers to query the table for an existing match on insert or update.

    Hashing comes with the caveat that one day, you might get a collision.

    Triggers will scan the entire table.

    Over to you...

提交回复
热议问题