1
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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Krishan Gopal
  • 4,073
  • 1
  • 16
  • 19
  • 2
    Well, if you want to defrag your table, then yes it will work. see here: http://dev.mysql.com/doc/refman/5.0/en/innodb-file-defragmenting.html – reptildarat Jul 23 '14 at 09:03

3 Answers3

1

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:

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;
Community
  • 1
  • 1
uzasnik
  • 56
  • 5
0

I am not sure for optimizing existing table but I can corrected your query.

ALTER TABLE `mytable` ENGINE = InnoDB;
Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
0

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.

juergen d
  • 201,996
  • 37
  • 293
  • 362