Thursday, March 19, 2026

Oracle Impdp options views_as_tables and DATA_OPTIONS =trust_existing_table_partitons



VIEWS_AS_TABLES (used in expdp to materialize views as physical tables) and TRUST_EXISTING_TABLE_PARTITIONS (used in impdp to optimize partition loading) are Data Pump features to manage complex data structures and performance. 

VIEWS_AS_TABLES enables exporting view data as tables, while TRUST_EXISTING_TABLE_PARTITIONS skips unnecessary partition validation, accelerating imports. 


VIEWS_AS_TABLES


VIEWS_AS_TABLES is a neat feature in Oracle Data Pump that allows you to export the contents of a view and import them as tables.


The idea is to export a view as if it were a table. The dump file contains a table definition:

With the same name as the view
With the same columns as the view
With the same data as the view
SQL> CREATE VIEW oraview as SELECT * FROM oracledbwr;
View created.

Now export the view using the VIEWS_AS_TABLES parameter.

[oracle@prod101:admin orcl101] expdp scott/tiger views_as_tables=oraview directory=test_dir dumpf



TRUST_EXISTING_TABLE_PARTITIONS 


Another important option is TRUST_EXISTING_TABLE_PARTITIONS  .
TRUST_EXISTING_TABLE_PARTITIONS Loads partition data in parallel into existing partitions on the destination database. The partitions must already be present with the correct attributes.

Full list of data options are below 

# Export
DATA_OPTIONS = [XML_CLOBS | GROUP_PARTITION_TABLE_DATA | VERIFY_STREAM_FORMAT]

# Import
DATA_OPTIONS = [DISABLE_APPEND_HINT | SKIP_CONSTRAINT_ERRORS | 
               ENABLE_NETWORK_COMPRESSION | REJECT_ROWS_WITH_REPL_CHAR | 
               TRUST_EXISTING_TABLE_PARTITIONS | VALIDATE_TABLE_DATA]

These settings are described in the manuals (export, import), but they are briefly described below.

  • GROUP_PARTITION_TABLE_DATA : Unloads all partitions as a single operation producing a single partition of data in the dump file. Subsequent imports will not know this was originally made up of multiple partitions.
  • VERIFY_STREAM_FORMAT : Validates the format of the data stream before it is written to the dump file, so you are less likely to have problems with the contents of the dumpfile.
  • ENABLE_NETWORK_COMPRESSION : Compresses data during network imports using the ACCESS_METHOD of DIRECT_PATH. There are some caveats described here.
  • TRUST_EXISTING_TABLE_PARTITIONS : Loads partition data in parallel into existing partitions on the destination database. The partitions must already be present with the correct attributes.
  • VALIDATE_TABLE_DATA : Validates numbers and dates during imports. Writes ORA-39376 errors inclduing the column information to the log file if it finds invalid data.

No comments:

Post a Comment