Retrieving, executing and saving partial data from SQL dump

  • You are here: Free PHP » Classes » Retrieving, executing and saving partial data from SQL dump
Screenshot
Package:
Retrieving, executing and saving partial data from SQL dump
Summary:
Extract table dumps from full MySQL database dumps
Groups:
Databases, PHP 5, Systems administration
Author:
Alexander Selifonov
Description:
This class can be used to extract table dumps from full MySQL database dumps.

It can parse a MySQL full database and extract the SQL CREATE and INSERT statements just for given tables.

The extracted SQL statements may be executed immediately or saved to a new database dump file.

Sometimes database administrators or programmers need to restore or copy only a few data tables from one server to another, but all they have is a full DUMP file created by standard utilities like 'dump' (for MySQL).
For production systems it can be really HUGE file, so the task seems to be not so simple.

CDataFromDump class aimed to resolve the problem: it parses source dump file and grabs only data for desired table list. These CREATE TABLES and INSERT operators can be instantly executed on connected database or saved into a new SQL file, for editing and/or executing later.

Currently the class has following features:
- During the first scan, it tries to creates "metadata" file for processed dump, so next retrieving jobs will be much faster.
- Grabs only SQL operators for the tables from passed list
CREATE TABLE operators can be executed/included into result SQL file or NOT, according to passed parameters.


Powered by Gewgley