Name

RESTORE TABLE

Synopsis

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

Use this statement to restore 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 is given 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.

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. The .MYI files were generated automatically after they were restored.

Get MySQL in a Nutshell 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.