• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Techgoeasy

Techgoeasy

Learn Oracle, PHP, HTML,CSS,Perl,UNIX shell scripts

  • Home
  • Oracle
    • Oracle database
    • Oracle Ebusiness Suite
    • Oracle weblogic
    • Oracle Performance Tuning
    • Oracle Hyperion
    • Oracle Cloud Tutorials
  • SQL
  • interview questions
  • Linux
  • PHP and HTML
  • Downloads
  • General
Home » Oracle » Oracle Database » How to transfer statistics between databases in Oracle

How to transfer statistics between databases in Oracle

May 5, 2023 by techgoeasy Leave a Comment

We can transfer statistics between servers allowing consistent execution plans between servers with varying amounts of data. This is possible using the DBMS_STATS package

Here are the steps to do for a table

Step 1. Create the stat table

EXEC DBMS_STATS.CREATE_STAT_TABLE('SCOTT,'STATTAB', 'TOOLS'); 

Step 2 Export table statistics to statistics table.

EXEC DBMS_STATS.EXPORT_TABLE_STATS(OWNNAME=>'SCOTT',TABNAME=>'EMP', STATTAB=>'STATTAB',STATID=>'EXP_1',STATOWN=>'SCOTT);

Step 3 Export the user statistics table into an exp file

exp file=stats.dmp log=stats_exp.log tables=scott.stattab

Step 4 Import the exp file into another database

imp file=stats.dmp log=statistisc_import.log

Step 5 Import table statistics from the statistics table to the data dictionary table

EXEC DBMS_STATS.IMPORT_TABLE_STATS(OWNNAME=>'SCOTT',TABNAME=>'EMP', STATTAB=>'STATTAB',STATID=>'EXP_1',STATOWN=>'SCOTT);

Step 6 Drop the stat table

EXEC DBMS_STATS.DROP_STAT_TABLE('SCOTT','STATTAB');

Here are the steps to do for a schema

Step 1. Create the stat table

EXEC DBMS_STATS.CREATE_STAT_TABLE('SCOTT,'STATTAB', 'TOOLS'); 

Step 2 Export schema statistics to the user statistics table.

EXEC DBMS_STATS.EXPORT_SCHEMA_STATS(OWNNAME=>'SCOTT', STATTAB=>'STATTAB',STATID=>'EXP_SC_1',STATOWN=>'SCOTT');

Step 3 Export the user statistics table into an exp file

exp file=stats.dmp log=stats_exp.log tables=scott.stattab

Step 4 Import the exp file into another database

imp file=stats.dmp log=statistisc_import.log

Step 5 Import the schema stats from the User statistics table to the data dictionary

EXEC DBMS_STATS.IMPORT_SCHEMA_STATS(OWNNAME=>'SCOTT', STATTAB=>'STATTAB',STATID=>'EXP_SC_1',STATOWN=>'SCOTT');

Hope you like this article on How to transfer statistics between databases in Oracle

Related Articles
How to import statistics in Oracle
How to create stat table in Oracle
How to delete statistics from Table in Oracle 
How to check column statistics in Oracle
How to export statistics in Oracle

Filed Under: Oracle, Oracle Database

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Subscribe to our mailing list

Enter your email address to subscribe to this blog and receive notifications of new posts by email

Recent Posts

  • Top Queries on Sql plan Management
  • Move SQL Baseline from One Database to Another in Oracle
  • How to drop the sql baseline in Oracle
  • how to create sql baseline from AWR repository without STS
  • how to create sql baseline from Sql tuning set in Oracle

Copyright © 2023 : TechGoEasy

  • Hire me
  • Privacy Policy
  • Contact Us
  • New? Start Here
  • About Us
x
x