Name

RESTORE TABLE

Synopsis

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

This statement restores a table that was saved to the filesystem by the BACKUP TABLE statement. Multiple 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 BACKUP TABLE statement doesn’t back up the index files. Here is an example of this 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 is successful in restoring the .frm and .MYD files located in the backup directory and regenerating the .MYI files.

Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.