Mohammad Ali Akbari
Mohammad Ali Akbari

Reputation: 10395

is there any limit for VARCHAR columns to be index-able in mySql?

I know there isn't any limit for a VARCHAR column, and it can be up to ROW limit size in mysql (65,535 bytes).

now is there any limit for VARCHAR column to be index-able? or dose it depend on Storage Engines?

Upvotes: 1

Views: 1505

Answers (1)

Devart
Devart

Reputation: 121902

Yes, there is a limitation:

From the documentation - All storage engines support at least 16 indexes per table and a total index length of at least 256 bytes. Most storage engines have higher limits.

More information - Column Indexes.

In this case you can specify a prefix length for the index, e.g. -

CREATE TABLE table1 (
  column1 VARCHAR(255) DEFAULT NULL,
  UNIQUE KEY UK_table1_column1 (column1(10))
);

Upvotes: 1

Related Questions