Mysql, InnoDB to MyISAM for fulltext index - mysql

Actually, I would like to switch the engine of my tables. There are in InnoDB and I want to set them to MyISAM because of this
ALTER TABLE `xxx_db`.`yyy` ADD FULLTEXT `ft_modele` (
`anno_modele`
)
Error :
Documentation
#1214 - The used table type doesn't support FULLTEXT indexes
So... I do this :
ALTER TABLE `annonce` ENGINE = MYISAM
But I have an error too :
#1217 - Cannot delete or update a parent row: a foreign key constraint fails
I understand the error... but I don't really want to kill all my references index, and re-create them. Too long.
Someone has an idea to convert innoDB to MyISAM ? I read that fulltext is supported for MySQL 5.6.4 ... unfortunately I have 5.5.28 and I'm on Plesk 11. I fear if I do an upgrade, my server crashs.
Someone can help me ?

Fulltext indexes or foreign key constraints (MyISAM does not support those) you can only chose one (until MySQL 5.6 that is).
Changing database engine will result in total table rewrite (creating a new one, moving data, dropping the old one) anyway.
If I were you, I would go for the upgrade.

Unfortunately you can't have a table in MySQL 5.5 that supports both foreign key constraints and fulltext indexes. As you've already noted MySQL 5.6 does support fulltext indexes for InnoDB.
I recommend updating MySQL if possible. MySQL 5.6 is stable.
Alternatively use an external full text index like Sphinx or Lucene

Unformtunately, there is no good option for me. While there is not an upgrade for plesk with the new version of mysql, i can't upgrade the server without create instability.
So, I just mysqldump my database and edit tables and keys.
Tank for the help. Have a nice day

Related

Using ALTER for Table Optimization (MySql)

ALTER TABLE [tbl_name] TYPE=innodb
I have just read somewhere that using above alter table statement will optimize an existing table. I am not very sure that this would work and if yes, does it work even if table type is already InnoDB?
InnoDB:
The InnoDB storage engine in MySQL.
Support for transactions (giving you support for the ACID property).
Row-level locking. Having a more fine grained locking-mechanism gives you higher concurrency compared to, for instance, MyISAM.
Foreign key constraints. Allowing you to let the database ensure the integrity of the state of the database, and the relationships between tables.
InnoDB is more resistant to table corruption than MyISAM.
Support for large buffer pool for both data and indexes. MyISAM key buffer is only for indexes.
Another point is that MyISAM is stagnant; all future enhancements will be in InnoDB
InnoDB Limitations:
No full text indexing (Below-5.6 mysql version)
Cannot be compressed for fast, read-only
For more info on this:
http://www.kavoir.com/2009/09/mysql-engines-innodb-vs-myisam-a-comparison-of-pros-and-cons.html
When to use MyISAM and InnoDB?
http://dev.mysql.com/doc/refman/5.0/en/innodb-file-defragmenting.html
If your DB is already a innoDB you do not need to make that statement again. As for other suggestions you should use ENGINE instead of TYPE.
ALTER TABLE `table_name` ENGINE = InnoDB;
I am not sure for optimizing existing table but I can corrected your query.
ALTER TABLE `mytable` ENGINE = InnoDB;
Use the ENGINE keyword since TYPE is not supported any more
As of MySQL 5.1.8, TYPE = engine_name is still accepted as a synonym for the ENGINE = engine_name table option but generates a warning. You should note that this option is not available in MySQL 5.1.7, and is removed altogether in MySQL 5.5 and produces a syntax error.
After that your query should work and change the engine for an existing table.

reorder a column with phpMyAdmin using InnoDB storage engine does not work

Today I tried to reorder a column of a table using phpMyAdmin (as I have done many times before).
Although the result was displayed as successful no reordering effectively happened.
It appears the problem is caused by using InnoDB as storage engine which is the default value from MySQL 5.5 onward.
When I changed back to myIsam the problem was solved. It clarified why it was working on some tables.
Is this a solvable mySQL problem? Or is this regular expected behavior for InnoDB ?
In the latter case phpMyAdmin should perhaps be adapted to not offer the functionality while using InnoDB.
MySQL: 5.5.29
phpMyAdmin: 4.0.4
If by ...reordering column... you meant
ALTER TABLE ... ORDER BY ...
then for InnoDB table that has a PRIMARY or UNIQUE KEY it doesn't work. It's by design:
ALTER TABLE
ORDER BY does not make sense for InnoDB tables that contain a
user-defined clustered index (PRIMARY KEY or NOT NULL UNIQUE index).
InnoDB always orders table rows according to such an index if one is
present.
On the other hand if you don't have PRIMARY or UNIQUE KEY in your table, which is highly unlikely, then MySQL will allow you to change the order.
Here is SQLFiddle demo that demonstrates that behavior.

MySQL error when altering table to Fulltext

I get an error #1283 - Column 'title' cannot be part of FULLTEXT index when I try to include the columns I want to alter via FULLTEXT in my database.
ALTER TABLE users ADD FULLTEXT (`firstname`, `lastname`, `title`, `description`)
I'm not understanding why this error shows or how to go about in fixing this problem. Would be grateful for any ideas or tips.
NOTE: This post applies to old version of MySQL. Starting from
version 5.6, INNODB supports FULLTEXT index and the below code should not be used. Leaving the original answer for reference.
FULLTEXT index works only on MyISAM tables, not on InnoDB. You can check what storage enging you use by typing:
SHOW CREATE TABLE users;
then, you could ALTER the table to use MyISAM engine using this command:
ALTER TABLE users ENGINE = MyISAM;
Starting from Mysql 5.6, INNODB now supports FULLTEXT INDEX. Now I also ran into this issue when adding FULLTEXT to a table of mine and ran into multiple issues.
you need to insure your ibdata1 file is set to autoextend. http://dev.mysql.com/doc/refman/5.0/en/innodb-data-log-reconfiguration.html
I was running out of diskspace. While mysql alters a table, mysql uses tmp data and memory to do so. You need to make sure your tmp dir in you cnf file is pointing to a directory with enough space. Also, since it uses memory, it will use your Virtual Memory. Meaning your OS drive needs to have enough space. If this is not an option, create a tmp duplicate tmp table and alter that table with the fulltext and right an INSERT INTO table SELECT * FROM og_table
If your table is InnoDB then you can not use it. And need to drop it.
You can also refer to limitations of InnoDB # http://dev.mysql.com/doc/refman/5.5/en/innodb-restrictions.html
INNODB supports FULLTEXT INDEX since Mysql 5.6
To avoid errors "Column * cannot be part of FULLTEXT index"
check TEXT INCODING of your columns ;) It must be the same.

MySQL change engine on tables with Foreign Keys

So, in the process of creating our tables, we weren't paying close enough attention to our system and all of the tables were created with the InnoDB engine. This is really only bad because we want to have a FULLTEXT index on a few of the columns.
So, now I want to convert. And while I'm at it, I just want to convert all the tables to MyISAM so that if we ever add columns in the future that we want to index, we have that option. So I've got my .sql file with the following:
ALTER TABLE tableName1 Engine = MyISAM;
ALTER TABLE tableName2 Engine = MyISAM;
However, when I try to run it, I get the following error:
Error Code: 1217 Cannot delete or update a parent row: a foreign key constraint fails
As you might have guessed, we have foreign keys in our tables. Not my style, but also not my department, nor my creation script.
My question boils down to, is there anyway for me to change the engine on these tables without having to wipe the DB?
Edit: Note that this will need to be done on multiple development and test copies of the database, so something I can script would definitely be preferred.
Well, to my knowledge, sort of but not really. mysqldump the database and edit out the foreign key constraints in the dumped sql file. And of course change the engine in the CREATE TABLE script.
InnoDB unlike MyISAM support foreign keys and has lots of great features like transactional system that ensures integrity across all tables. MyISAM tables tend to fail now and then when you have large data in tables or for many other reasons.
In the near future InnoDB will implement FullText search. I recommend not to change tables' engine but have something like Sphinx in place. Sphinx is much more powerful and much more flexible than Fulltext Search which works for InnoDB.
More about fulltext search in InnoDB:
InnoDB Fulltext search

MySQL FULLTEXT indexes issue

I’m trying to create a FULLTEXT index on an attribute of a table. Mysql returns
ERROR 1214: The used table type doesn’t support FULLTEXT indexes.
Any idea what I’m doing wrong?
You’re using the wrong type of table. Mysql supports a few different types of tables, but the most commonly used are MyISAM and InnoDB. MyISAM (in MySQL 5.6+also InnoDB tables) are the types of tables that Mysql supports for Full-text indexes.
To check your table’s type issue the following sql query:
SHOW TABLE STATUS
Looking at the result returned by the query, find your table and corresponding value in the Engine column. If this value is anything except MyISAM or InnoDB then Mysql will throw an error if your trying to add FULLTEXT indexes.
To correct this, you can use the sql query below to change the engine type:
ALTER TABLE <table name> ENGINE = [MYISAM | INNODB]
Additional information (thought it might be useful):
Mysql using different engine storage types to optimize for the needed functionality of specific tables. Example MyISAM is the default type for operating systems (besides windows), preforms SELECTs and INSERTs quickly; but does not handle transactions. InnoDB is the default for windows, can be used for transactions. But InnoDB does require more disk space on the server.
Up until MySQL 5.6, MyISAM was the only storage engine with support for full-text search (FTS) but it is true that InnoDB FTS in MySQL 5.6 is syntactically identical to MyISAM FTS. Please read below for more details.
InnoDB Full-text Search in MySQL 5.6
On MySQL <= 5.5, the mysql manual says that FULLTEXT indexes can only be created on tables with the mylsam engine.
Are you using InnoDB? The only table type that supports FULLTEXT is MyISAM.
apart from MyISAM table PARTITIONING also not support full-text index.