{"id":4127,"date":"2025-06-08T10:04:16","date_gmt":"2025-06-08T10:04:16","guid":{"rendered":"https:\/\/w3buddy.com\/?post_type=cposts&#038;p=4127"},"modified":"2025-06-08T10:04:17","modified_gmt":"2025-06-08T10:04:17","slug":"oracle-table-refresh","status":"publish","type":"cposts","link":"https:\/\/w3buddy.com\/blog\/notes\/oracle-dba-d2d-tasks\/oracle-table-refresh\/","title":{"rendered":"Oracle Table Refresh"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Table Refresh<\/strong> means updating or replacing one or more tables on a target database from a source database using Data Pump (expdp\/impdp), minimizing downtime and ensuring consistent data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps on Target Database (Prechecks &amp; Backup)<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">Although you may plan on source, these must run on target DB before refresh:<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">1. Check if table exists on target<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>SELECT table_name FROM all_tables WHERE owner = 'TARGET_SCHEMA' AND table_name = 'YOUR_TABLE';<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Check row count on target<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>SELECT COUNT(*) FROM target_schema.your_table;<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Backup target table (for revert safety)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>nohup expdp '\"\/ as sysdba\"' DIRECTORY=my_dump_dir DUMPFILE=your_table_bkp_%U.dmp LOGFILE=your_table_bkp.log TABLES=target_schema.your_table COMPRESSION=ALL PARALLEL=4 REUSE_DUMPFILES=Y &amp;<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Steps on Source Database (Export)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">4. Export table from source DB<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>nohup expdp '\"\/ as sysdba\"' DIRECTORY=my_dump_dir DUMPFILE=your_table_%U.dmp LOGFILE=your_table_exp.log TABLES=source_schema.your_table COMPRESSION=ALL PARALLEL=4 REUSE_DUMPFILES=Y &amp;<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Steps on Target Database (Import)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">5. Transfer dump files to target if source and target don\u2019t share filesystem<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>scp \/path\/to\/dump\/your_table_*.dmp oracle@target_server:\/path\/to\/dump\/\nscp \/path\/to\/dump\/your_table_exp.log oracle@target_server:\/path\/to\/dump\/<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">More info: <a href=\"https:\/\/w3buddy.com\/blog\/notes\/oracle-dba-d2d-tasks\/scp-file-transfer\/\" target=\"_blank\" rel=\"noreferrer noopener\">SCP File Transfer<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. Create Directory Object on target (if not present)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code><code>CREATE DIRECTORY my_dump_dir AS '\/path\/to\/dump';\nGRANT READ, WRITE ON DIRECTORY my_dump_dir TO target_user;<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">More info: <a href=\"https:\/\/w3buddy.com\/blog\/notes\/oracle-dba-d2d-tasks\/create-directory\/\" target=\"_blank\" rel=\"noreferrer noopener\">Create Directory<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7. Import Table(s) \u2014 Different Types of Table Refresh (choose as per need)<\/h3>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th>Type<\/th><th>When to Use<\/th><th>Import Command Example<\/th><\/tr><\/thead><tbody><tr><td><strong>Full Refresh (REPLACE)<\/strong><\/td><td>Replace entire table data<\/td><td><code>nohup impdp '\"\/ as sysdba\"' DIRECTORY=my_dump_dir DUMPFILE=your_table_%U.dmp LOGFILE=your_table_imp.log TABLES=your_table TABLE_EXISTS_ACTION=REPLACE PARALLEL=4 &amp;<\/code><\/td><\/tr><tr><td><strong>Append Data (APPEND)<\/strong><\/td><td>Add new rows to existing data<\/td><td><code>nohup impdp '\"\/ as sysdba\"' DIRECTORY=my_dump_dir DUMPFILE=your_table_%U.dmp LOGFILE=your_table_imp.log TABLES=your_table TABLE_EXISTS_ACTION=APPEND PARALLEL=4 &amp;<\/code><\/td><\/tr><tr><td><strong>Truncate &amp; Load (TRUNCATE)<\/strong><\/td><td>Delete all rows first, then load new data<\/td><td><code>nohup impdp '\"\/ as sysdba\"' DIRECTORY=my_dump_dir DUMPFILE=your_table_%U.dmp LOGFILE=your_table_imp.log TABLES=your_table TABLE_EXISTS_ACTION=TRUNCATE PARALLEL=4 &amp;<\/code><\/td><\/tr><tr><td><strong>Skip If Exists (SKIP)<\/strong><\/td><td>Import only if table does not exist<\/td><td><code>nohup impdp '\"\/ as sysdba\"' DIRECTORY=my_dump_dir DUMPFILE=your_table_%U.dmp LOGFILE=your_table_imp.log TABLES=your_table TABLE_EXISTS_ACTION=SKIP PARALLEL=4 &amp;<\/code><\/td><\/tr><tr><td><strong>Subset Rows (QUERY)<\/strong><\/td><td>Refresh partial data (filtered rows)<\/td><td>Export with QUERY:<br><code>nohup expdp '\"\/ as sysdba\"' DIRECTORY=my_dump_dir DUMPFILE=your_table_%U.dmp LOGFILE=your_table_exp.log TABLES=your_table QUERY=\"WHERE created_date &gt; TO_DATE('2024-01-01','YYYY-MM-DD')\" COMPRESSION=ALL PARALLEL=4 REUSE_DUMPFILES=Y &amp;<\/code><br>Import as full refresh example<\/td><\/tr><tr><td><strong>Multiple Tables<\/strong><\/td><td>Refresh multiple tables together<\/td><td>Export:<br><code>nohup expdp '\"\/ as sysdba\"' DIRECTORY=my_dump_dir DUMPFILE=multi_tables_%U.dmp LOGFILE=multi_tables_exp.log TABLES=table1,table2,table3 COMPRESSION=ALL PARALLEL=4 REUSE_DUMPFILES=Y &amp;<\/code><br>Import as full refresh example<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Reference \u2014 Important expdp\/impdp Parameters for Table Refresh<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><code>nohup expdp|impdp '\"\/ as sysdba\"' DIRECTORY=directory_name\n  DUMPFILE=your_table_%U.dmp &#91;,more_files]\n  LOGFILE=logfile_name.log\n  FULL=Y|N\n  SCHEMAS=schema_name &#91;,schema_name]\n  TABLES=table_name &#91;,table_name] or owner.tablename\n  QUERY=table_name:\"WHERE condition\"\n  TABLE_EXISTS_ACTION=REPLACE|APPEND|TRUNCATE|SKIP\n  PARALLEL=number_of_threads\n  REUSE_DUMPFILES=Y|N\n  COMPRESSION=ALL|DATA|METADATA|NONE\n  CONTENT=ALL|DATA_ONLY|METADATA_ONLY\n  NETWORK_LINK=network_link_name\n  FLASHBACK_TIME=\"timestamp\"\n  ENCRYPTION=ALL|DATA|METADATA|NONE\n  ENCRYPTION_PASSWORD=password\n  DISABLE_ARCHIVE_LOGGING=Y|N\n  ROWS=Y|N\n  VERSION=version_number\n  JOB_NAME=job_name<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For Oracle Data Pump dump file naming, besides <code>%U<\/code>, these are the common substitution parameters you can use in the <strong>DUMPFILE<\/strong> parameter:<\/p>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th>Parameter<\/th><th>Meaning<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td><code>%U<\/code><\/td><td>Universal file name \u2014 automatically generated unique dump file part (used for parallel jobs)<\/td><td><code>your_table_%U.dmp<\/code> \u2192 <code>your_table_01.dmp<\/code>, <code>your_table_02.dmp<\/code>, etc.<\/td><\/tr><tr><td><code>%I<\/code><\/td><td>Instance number (useful in RAC environments)<\/td><td><code>your_table_%I_%U.dmp<\/code> \u2192 <code>your_table_1_01.dmp<\/code>, <code>your_table_2_01.dmp<\/code><\/td><\/tr><tr><td><code>%p<\/code><\/td><td>Job name prefix<\/td><td><code>your_table_%p_%U.dmp<\/code> \u2192 <code>your_table_myjob_01.dmp<\/code><\/td><\/tr><tr><td><code>%j<\/code><\/td><td>Job name<\/td><td><code>your_table_%j_%U.dmp<\/code> \u2192 <code>your_table_myjob_01.dmp<\/code> (similar to <code>%p<\/code>)<\/td><\/tr><tr><td><code>%d<\/code><\/td><td>Directory object name<\/td><td><code>your_table_%d_%U.dmp<\/code> \u2192 <code>your_table_my_dir_01.dmp<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Notes:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>%U<\/code> is most commonly used because it guarantees unique file names for parallel jobs.<\/li>\n\n\n\n<li><code>%I<\/code> is particularly useful in RAC to differentiate files by instance.<\/li>\n\n\n\n<li><code>%p<\/code> and <code>%j<\/code> are based on the job name, making it easier to identify dump files belonging to a specific job.<\/li>\n\n\n\n<li><code>%d<\/code> adds the directory object name, useful if you manage multiple directories.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Table Refresh means updating or replacing one or more tables on a target database from a source database using Data Pump (expdp\/impdp), minimizing downtime and ensuring consistent data. Steps on Target Database (Prechecks &amp; Backup) Although you may plan on source, these must run on target DB before refresh: 1. Check if table exists on [&hellip;]<\/p>\n","protected":false},"template":"","meta":{"googlesitekit_rrm_CAowu461DA:productID":""},"categories":[952,984],"class_list":["post-4127","cposts","type-cposts","status-publish","hentry","category-notes","category-oracle-dba-d2d-tasks"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts\/4127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts"}],"about":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/types\/cposts"}],"wp:attachment":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=4127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=4127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}