Monday, October 22, 2012

Converting table to InnoDB

Converting table to InnoDB

Converting table to InnoDB: “The used table type doesn’t support FULLTEXT indexes”

Somtimes you may want to change the Mysql table from MyISAM to InnoDB engine to setup foreign keys, to use row level locks, improve performace etc.

The conversion of the MyISAM table to InnoDB is easy however, if the table is setup with “FULLTEXT indexes”, it cannot be converted as this feature is not supported in InnoDB.

If a table is setup with “FULLTEXT indexes”, the conversion of table to InnoDB will result in “The used table type doesn’t support FULLTEXT indexes” error message.

mysql> ALTER TABLE test ENGINE=InnoDB;
ERROR 1214: The used table type doesn’t support FULLTEXT indexes
The solution is to remove “FULLTEXT indexes” from the table before converting to InnoDB. To check if the table is setup with FULLTEXT indexes, execute:

mysql> show create table test;
————————
| Table | Create Table
————————
| test | CREATE TABLE `test` (
`col_name` varchar(10) DEFAULT NULL,
FULLTEXT KEY `keyname` (`col_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
If FULLTEXT is setup, the output of the above command will display a line as follows:
FULLTEXT KEY `keyname` (`col_name`)

Now, remove “FULLTEXT” indexes from the table:

mysql> ALTER TABLE test DROP INDEX keyname;

Now, this table can be converted to InnoDB using the following command:

mysql> ALTER TABLE test ENGINE=InnoDB;
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0

No comments:

Post a Comment