Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Indexing a MySql TEXT column?

Tags:

indexing

mysql

People also ask

Can you index a string column?

Any index in SQL Server can be a maximum of 900 bytes per index entry - if your string column is longer than that, you cannot index it.

How do I index a column in MySQL?

To create indexes, use the CREATE INDEX command: CREATE INDEX index_name ON table_name (column_name); You can an index on multiple columns.

What is full-text indexing in MySQL?

Full-text indexes are created on text-based columns ( CHAR , VARCHAR , or TEXT columns) to speed up queries and DML operations on data contained within those columns. A full-text index is defined as part of a CREATE TABLE statement or added to an existing table using ALTER TABLE or CREATE INDEX .

Which column should be indexed in MySQL?

column the first in the composite index (in my case that would be the Showtime column). The only problem with that is that the index can only be used by the database if the first column is included in the search query, which it currently isn't in either of my queries.


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));

Two things:

  1. Key is a reserved word.
  2. You have to specify a length for a UNIQUE(key) TEXT value.

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.)