From O'Reilly MySQL Certification Study Guide:There are three ways to check tables. All of these work with MyISAM tables, the default, non-transactional table type, and one with InnoDB, the most mature of the MySQL transactional table types. Fortunately, MySQL now allows you to check tables while the server is still running, so corruption in a minor table need not affect everything on the server.
- The CHECK TABLE SQL statement (obviously the server must be running for this)
- Running the mysqlcheck command-line utility (the server can be running)
- Running the myisamchk command-line utility (the server must be down, or the tables inactive)
Checking Tables with mysqlcheck and myisamchk
The mysqlcheck and myisamchk programs are used to check and repair tables (primarily MyISAM tables). They can help you keep your tables free from problems, or repair them if problems do occur—for example, if a MyISAM table becomes damaged as the result of a server crash.
mysqlcheck and myisamchk are similar in purpose, but they do have some differences. Here's a comparison of the two programs:
From mysqlcheck — A Table Maintenance and Repair Program by MySQL AB:
The mysqlcheck client checks, repairs, optimizes, and analyzes tables.
mysqlcheck is similar in function to myisamchk, but works differently. The main operational difference is that mysqlcheck must be used when the mysqld server is running, whereas myisamchk should be used when it is not. The benefit of using mysqlcheck is that you do not have to stop the server to check or repair your tables.
mysqlcheck uses the SQL statements
TheCHECK TABLE,REPAIR TABLE,ANALYZE TABLE, andOPTIMIZE TABLEin a convenient way for the user. It determines which statements to use for the operation you want to perform, and then sends the statements to the server to be executed. For details about which storage engines each statement works with, see the descriptions for those statements in Chapter 12, SQL Statement Syntax.MyISAMstorage engine supports all four statements, so mysqlcheck can be used to perform all four operations onMyISAMtables. Other storage engines do not necessarily support all operations. In such cases, an error message is displayed.
No comments:
Post a Comment