Copy a Table and Associated Statistics
You can copy a table and its associated optimizer statistics from one database to another using copydb and statistics that have been unloaded to a text file. This is usually much faster than copying only the table and rerunning the optimization process to recreate the statistics.
Note: Copying a table and its statistics makes sense only if the statistics are up-to-date.
First, unload the table and its statistics to text files, as described in the steps below:
1. Enter the following command to generate copy.in and copy.out scripts for the arel table:
copydb olddb arel
2. Copy the are1 table out of the olddb database:
sql olddb <copy.out
3. Unload the statistics for the are1 table to a text file named are1.dat:
statdump -o arel.dat olddb -rarel
(Or use Director or VDBA.)
Next, copy the table and statistics back into the new database:
4. Copy the are1 table into the new database:
sql newdb <copy.in
5. Load the statistics for the are1 table from the text file are1.dat in Step 3 of the previous example:
optimizedb -i arel.dat newdb -rarel
(Or use Director or VDBA.)