Recently, we took a live/online backup of our production database, by issuing the following command:
expdp system/******@SID FULL=y DIRECTORY=data_pump_dir DUMPFILE=full_prod.dmp LOGFILE=full_prod_export.log JOB_NAME=prod_backup
There were no errors nor warnings.
We then took this dump and created a number of developer databases from it, by issuing:
impdp system/******@SID SCHEMAS=MY_SCHEMA DIRECTORY=data_pump_dir DUMPFILE=full_prod.dmp LOGFILE=full_prod_import.log
Again, no errors nor warnings.
Once the developer environments were set-up, the developers launched their applications and tried to insert some test data. The first few attempts failed with primary key violations. After a bit of digging, it turns out that the cached sequences (NOCACHE sequences were fine) were generally behind by one or two values.
An example is the sequence for our contact table:
CREATE SEQUENCE REQ_CONTACT_SEQ
START WITH 213041
MAXVALUE 999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER;
Oracle shows a last cached value of 213041 for this sequence. Now, when I run the following query:
SELECT MAX(id) FROM REQ_CONTACT;
Oracle returns 213042
. It's obvious that this value is 1 higher than the sequence.
So.... My question is, did we only get this result because we took the Data Export while production was live - ie there were open and active connections to the database? Or does Data Pump have a problem with sequences that are cached? We are using Oracle 10.2.0.4.
Thanks, Muel.