When working with Oracle Data Pump (expdp), you may encounter issues exporting specific tables under the SYS schema. Below is a step-by-step example and explanation of why this happens.
Creating a Test Table
First, create a test table under the SYS schema to demonstrate the problem:
D:\app\product\11.1.0\db_1>sqlplus "/as sysdba"
SQL*Plus: Release 11.1.0.7.0 - Production on Sun May 18 17:12:06 2014
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> CREATE TABLE test_dump (id NUMBER, name VARCHAR2(30));
Table created.
SQL> SELECT t.table_name, tablespace_name, status FROM user_tables t WHERE t.table_name LIKE 'TEST%';
TABLE_NAME TABLESPACE_NAME STATUS
------------------------------ ------------------------------ --------
TEST_DUMP SYSTEM VALID
SQL> BEGIN
FOR i IN 1..100 LOOP
INSERT INTO test_dump VALUES (i, 'abc' || TO_CHAR(i));
END LOOP;
COMMIT;
END;
/
PL/SQL procedure successfully completed.
Attempting to Export
Next, attempt to export the test_dump table using expdp:
D:\app\product\11.1.0\db_1>expdp "sys/oracle as sysdba" DUMPFILE=aduit2.dmp DIRECTORY=expdump TABLES=sys.test_dump LOGFILE=testexp.log;
Export: Release 11.1.0.7.0 - 64bit Production on Sun May 18 17:18:38 2014
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLE_01": "sys/******** AS SYSDBA" DUMPFILE=aduit2.dmp DIRECTORY=expdump TABLES=sys.test_dump LOGFILE=testexp.log;
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 0 KB
ORA-39165: The schema SYS cannot be exported.
ORA-39166: Object TEST_DUMP was not found.
ORA-31655: No data or metadata objects have been selected for the job.
Job "SYS"."SYS_EXPORT_TABLE_01" completed with 3 errors at 17:18:40.
Root Cause
The issue arises because certain system schemas, such as SYS, are managed by Oracle and cannot be directly exported. According to the Oracle® Database Utilities 11g Release 2 (11.2), the following note explains this limitation:
Note: Several system schemas cannot be exported because they are not user schemas; instead, they contain Oracle-managed data and metadata. Examples of non-exportable system schemas include SYS, ORDSYS, and MDSYS.
This means that attempting to export tables from the SYS schema will fail due to they protected nature within the database architecture.