Indexing a MySql TEXT column?

后端 未结 3 1759
长发绾君心
长发绾君心 2020-12-05 12:59

I ran this using MySql and it appears to not like TEXT. With SQL server I use nvarchar(max) What should I use in MySql? In other tables some fields

相关标签:
3条回答
  • 2020-12-05 13:19

    I think it chokes on the key field name rather than the TEXT type (which should be perfectly fine).

    Reserved Words in mySQL

    (And as @Pablo already said, memo fields can't be unique.)

    0 讨论(0)
  • 2020-12-05 13:23

    Two things:

    1. Key is a reserved word.
    2. You have to specify a length for a UNIQUE(key) TEXT value.
    0 讨论(0)
  • 2020-12-05 13:40

    You can't have a UNIQUE index on a text column in MySQL.

    If you want to index on a TEXT or a BLOB field, you must specify a fixed length to do that.

    From MySQL documentation:

    BLOB and TEXT columns also can be indexed, but a prefix length must be given.

    Example:

    CREATE UNIQUE INDEX index_name ON misc_info (key(10));
    
    0 讨论(0)
提交回复
热议问题