注释:全文索引主要关联在数据类型为char,varchar和text的字段上,以便能够更加快速的查询数据量较大的字符串类型的字段。
1.create table table_name(
属性名 数据类型,
属性名 数据类型,
...
属性名 数据类型,
fulltext index|key 【索引名】(属性名1 【(长度)】 【ASC|DESC】)
);
for example; create table t_dept(
deptno int,
dname varchar(20),
loc varchar(20),
fulltext index index_loc(loc)
)engine=myisam;
----------------------------------------------
2.create fulltext index 索引名 on 表名 (属性名 【(长度)】 【ASC|DESC】)
for example: create fulltext index index_loc on t_dept(loc);
show create table t_dept \G;
explain select * from t_dept where dname='cj';
---------------------------------------------------
3.alter table table_name add fulltext index|key 索引名 (属性名 【(长度)】 【ASC|DESC】)
alter table t_dept add fulltext index index_loc(loc);
转载于:https://blog.51cto.com/xin521long/1832424