 |
|
Refresh test database from production schema
Oracle Database Tips by Donald Burleson |
Question: I want to schedule a weekly job to refresh
my test environment from my production database. What are my
options?
Answer: This is a common question, and you have many refreshing
options, depending on your environment. Any time you choose to migrate
"pieces" of the production schema, you run the risk of missing something
(current CBO statistics, sequences), so it's always best to do the whole schema,
if you have enough disk space.
Guidelines for refreshing a test database include:
- Current code - All PL/SQL and internal Java code must be kept
synchronized with production.
- Representative data - Whenever possible, a full-sized test and QA
instance are best.
- CBO statistics - It's critical to periodically refresh your test
database with current CBO statistics and workload (system) statistics.
There are several methods commonly-used for fast test database refreshes, and
they can all be reliably scheduled within Oracle, using
dbms_job or
dbms_scheduler:
1 - Database cloning - See my notes for a fast full clone of a production
database into test.
Cloning a regular
database.
Cloning a
RAC database.
2 - Export-Import
You have a wealth of option with Oracle data pump (export-import), including IGNORE=N, which forces you to pre-drop the tables in TEST, thereby
guaranteeing freshness. Here is a common approach to refreshing a test
database:
1 - Nuke all non-system objects in TEST - start fresh
2 - Export FULL from PROD and import into TEST
3 - Do full affirmative error checking (grep for "successfully completed" in the
import log
Whatever approach you use, this can be fully automated using the dbms_scheduler
package, but be careful to incorporate affirmative error checking to ensure that
it always runs correctly. Dr. Hall has some good examples of this in his Oracle
Job Scheduling book. It's a great book for creating bullet-proof jobs:
Oracle Job Scheduling book
 |
If you like Oracle tuning, see the book "Oracle
Tuning: The Definitive Reference", with 950 pages of tuning tips and
scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |