Fuzzy query of MySQL full-text index

Source: Internet
Author: User
Tags create index mysql version

Older versions of MySQL's full-text indexes can be used only on fields of char, varchar, and text in the MyISAM table.

However, the new version of the MySQL5.6.24 on the InnoDB engine also joined the full-text index, so the specific information you can always pay attention to the official website,
Let me talk about the use of MySQL full-text indexing, online a lot of, I only talk about what I know the drop part ha:
My MySQL version is:

Create a new table test:

CREATE TABLE' Test ' (' name 'Char( A) not NULL DEFAULT "', ' nickname 'Char( A) not NULL DEFAULT "', FulltextKEY' name ' (' Name ', ' nickname ')) ENGINE=InnoDBDEFAULTCHARSET=UTF8MB4;

Insert test data:

INSERT  into' Test ' (' name ', ' nickname ')VALUES("Matt", "I like Laravel");INSERT  into' Test ' (' name ', ' nickname ')VALUES("Matt", "I like Laravel");INSERT  into' Test ' (' name ', ' nickname ')VALUES("Gibson", "I don't like laravel ah");INSERT  into' Test ' (' name ', ' nickname ')VALUES("Gibson", "I will not Ah");INSERT  into' Test ' (' name ', ' nickname ')VALUES("Kevin", "I really won't");INSERT  into' Test ' (' name ', ' nickname ')VALUES("Mary", "I really won't");

OK, data interface and test data have been added, back to "full-text index" ... Let's say basic use:

1. Create a full-text index (fulltext index) 1.1. Create a full-text index while creating a table
CREATE TABLE' Test ' (' name 'Char( A) not NULL DEFAULT "', ' nickname 'Char( A) not NULL DEFAULT "', FulltextKEY' name ' (' Name ', ' nickname ')) ENGINE=InnoDBDEFAULTCHARSET=UTF8MB4;
1.2. Add by ALTER TABLE
ALTER TABLE ADD INDEX username  (' name ') #username  is the name of the index, either randomly or:ALTERTABLEADD fulltext username  (' Name ')
1.3. Directly through the CREATE INDEX method
CREATE INDEX  on ' Test ' (' name ') CREATE INDEX  on ' Test ' (' name ')# You can also specify the length of the index at the time the index is created
2. Delete full-text index 2.1. Use DROP Index directly (note: No drop fulltext Index this usage)
DROP INDEX  on test
2.2. How to use ALTER TABLE
ALTER TABLE DROP INDEX username;
3. Using Full-Text indexing

Slightly different from normal index

Format using full-Text indexing: MATCH (columnName) against (' string ')

Like what:

Not to be continued ...

Fuzzy query of MySQL full-text index

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.