![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_16461961187.webp)
Table Maintenance Statements
1167
REPAIR [NO_WRITE_TO_BINLOG | LOCAL] TABLE
tbl_name
[,
tbl_name
] ...
[QUICK] [EXTENDED] [USE_FRM]
REPAIR TABLE
repairs a possibly corrupted table. By default, it has the same effect as
myisamchk
--recover tbl_name
.
REPAIR TABLE
works for
MyISAM
and for
ARCHIVE
tables. See
Section 14.1, “The
MyISAM
Storage Engine”
, and
Section 14.8, “The
ARCHIVE
Storage Engine”
.
This statement requires
SELECT
[578]
and
INSERT
[577]
privileges for the table.
Normally, you should never have to run this statement. However, if disaster strikes,
REPAIR TABLE
is very likely to get back all your data from a
MyISAM
table. If your tables become corrupted often, you
should try to find the reason for it, to eliminate the need to use
REPAIR TABLE
. See
Section C.5.4.2,
“What to Do If MySQL Keeps Crashing”
, and
Section 14.1.4, “
MyISAM
Table Problems”
.
Caution
It is best to make a backup of a table before performing a table repair operation;
under some circumstances the operation might cause data loss. Possible
causes include but are not limited to file system errors. See
Chapter 7, Backup
and Recovery
.
Warning
If the server crashes during a
REPAIR TABLE
operation, it is essential after
restarting it that you immediately execute another
REPAIR TABLE
statement
for the table before performing any other operations on it. In the worst case,
you might have a new clean index file without information about the data file,
and then the next operation you perform could overwrite the data file. This is an
unlikely but possible scenario that underscores the value of making a backup
first.
REPAIR TABLE
returns a result set with the following columns.
Column
Value
Table
The table name
Op
Always
repair
Msg_type
status
,
error
,
info
,
note
, or
warning
Msg_text
An informational message
The
REPAIR TABLE
statement might produce many rows of information for each repaired table. The
last row has a
Msg_type
value of
status
and
Msg_test
normally should be
OK
. If you do not get
OK
for a
MyISAM
table, you should try repairing it with
myisamchk --safe-recover
. (
REPAIR TABLE
does not implement all the options of
myisamchk
.) With
myisamchk --safe-recover
, you can also
use options that
REPAIR TABLE
does not support, such as
--max-record-length
[324]
.
If you use the
QUICK
option,
REPAIR TABLE
tries to repair only the index file, and not the data file.
This type of repair is like that done by
myisamchk --recover --quick
.
If you use the
EXTENDED
option, MySQL creates the index row by row instead of creating one index at
a time with sorting. This type of repair is like that done by
myisamchk --safe-recover
.
The
USE_FRM
option is available for use if the
.MYI
index file is missing or if its header is corrupted.
This option tells MySQL not to trust the information in the
.MYI
file header and to re-create it using
information from the
.frm
file. This kind of repair cannot be done with
myisamchk
.
Note
Use the
USE_FRM
option only if you cannot use regular
REPAIR
modes! Telling
the server to ignore the
.MYI
file makes important table metadata stored
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...