RESTORE TABLE

This MySQL statement restores a table that was saved to the filesystem by the BACKUP TABLE statement, which is deprecated.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

RESTORE TABLE table[,  . . . ] FROM '/path'

Explanation

This MySQL statement restores a MySQL table that was saved to the filesystem by the MySQL statement, BACKUP TABLE. Multiple MySQL tables may be given in a comma-separated list. The absolute path to the directory containing the backup files must appear within quotes. If the tables already exist in the database, an error message will be generated and the restore will fail. If it's successful, the table indexes will be built automatically. This is necessary because the MySQL statement, BACKUP TABLE doesn't back up the index files.

Examples

Below is an example of this MySQL statement:

RESTORE TABLE clients, programmers FROM '/tmp/backup';

+--------------------------+---------+----------+----------+
| Table                    | Op      | Msg_type | Msg_text |
+--------------------------+---------+----------+----------+
| workrequests.clients     | restore | status   | OK       |
+--------------------------+---------+----------+----------+
| workrequests.programmers | restore | status   | OK       |
+--------------------------+---------+----------+----------+

In this example, the statement was successful in restoring the .frm and .MYD files located in the backup directory and regenerating the .MYI files.