oracle 10g new features1

Upload: sujaiyer83

Post on 07-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Oracle 10g New Features1

    1/26

    Oracle 10g New Features

    Automatic SQL Tuning in Oracle Database 10g

    This article the discusses the new features which automate the tuning of SQL statements in

    Oracle 10g:

    Overview

    SQL Tuning Advisor

    Managing SQL Profiles

    SQL Tuning Sets

    Useful Views

    Overview

    In its normal mode the query optimizer needs to make decisions about execution plans in a veryshort time. As a result it may not always be able to obtain enough information to make the bestdecision. Oracle 10g allows the optimizer to run in tuning mode where it can gather additionalinformation and make recommendations about how specific statements can be tuned further. Thisprocess may take several minutes for a single statement so it is intended to be used on high-loadresource-intensive statements.

    In tuning mode the optimizer performs the following analysis:

    Statistics Analysis - The optimizer recommends the gathering of statistics on objects withmissing or stale statistics. Additional statistics for these objects are stored in an SQLprofile.

    SQL Profiling - The optimizer may be able to improve performance by gathering

    additional statistics and altering session specific parameters such as theOPTIMIZER_MODE. If such improvements are possible the information is stored in anSQL profile. If accepted this information can then used by the optimizer when running innormal mode. Unlike a stored outline which fixes the execution plan, an SQL profile maystill be of benefit when the contents of the table alter drastically. Even so, it's sensible toupdate profiles periodically. The SQL profiling is not performed when the tuining optimizeris run in limited mode.

    Access Path Analysis - The optimizer investigates the effect of new or modified indexeson the access path. It's index recommendations relate to a specific statement so wherenecessary it will also suggest the use of the SQL Access Advisor to check the impact ofthese indexes on a representative SQL workload.

    SQL Structure Analysis - The optimizer suggests alternatives for SQL statements thatcontain structures that may impact on performance. The implementation of thesesuggestions requires human intervention to check their validity.

    The automatic SQL tuning features are accessible from Enterprise Manager on the "AdvisorCentral" page these or from PL/SQL using the DBMS_SQLTUNE package. This article will focus onthe PL/SQL API as the Enterprise Manager interface is reasonably intuative.

    http://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#overview#overviewhttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#sql_tuning_advisor#sql_tuning_advisorhttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#managing_sql_profiles#managing_sql_profileshttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#managing_sql_profiles#managing_sql_profileshttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#sql_tuning_sets#sql_tuning_setshttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#sql_tuning_sets#sql_tuning_setshttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#useful_views#useful_viewshttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#overview#overviewhttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#sql_tuning_advisor#sql_tuning_advisorhttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#managing_sql_profiles#managing_sql_profileshttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#sql_tuning_sets#sql_tuning_setshttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php#useful_views#useful_views
  • 8/6/2019 Oracle 10g New Features1

    2/26

    SQL Tuning Advisor

    In order to access the SQL tuning advisor API a user must be granted the ADVISOR privilege:CONN sys/password AS SYSDBAGRANT ADVISOR TO scott;CONN scott/tiger

    2) Overview

    The Automatic Database Diagnostic Monitor (ADDM) analyzes data in the Automatic WorkloadRepository (AWR) to identify potential performance bottlenecks. For each of the identified issuesit locates the root cause and provides recommendations for correcting the problem. An ADDManalysis task is performed and its findings and recommendations stored in the database everytime an AWR snapshot is taken provided the STATISTICS_LEVEL parameter is set to TYPICALorALL. The ADDM analysis includes:

    CPU load

    Memory usage I/O usage

    Resource intensive SQL

    Resource intensive PL/SQL and Java

    RAC issues

    Application issues

    Database configuration issues

    Concurrency issues

    Object contention

    3) Overview of Automatic Storage Management (ASM)

    Automatic Storage Management (ASM) simplifies administration of Oracle related files byallowing the administrator to reference disk groups rather than individual disks and files, whichare managed by ASM. The ASM functionality is an extention of the Oracle Managed Files (OMF)functionality that also includes striping and mirroring to provide balanced and secure storage. Thenew ASM functionality can be used in combination with existing raw and cooked file systems,along with OMF and manually managed files.

    The ASM functionality is controlled by an ASM instance. This is not a full database instance, justthe memory structures and as such is very small and lightweight.

    The main components of ASM are disk groups, each of which comprise of several physical disksthat are controlled as a single unit. The physical disks are known as ASM disks, while the filesthat reside on the disks are know as ASM files. The locations and names for the files are

    controlled by ASM, but user-friendly aliases and directory structures can be defined for ease ofreference.

    The level of redundancy and the granularity of the striping can be controlled using templates.Default templates are provided for each file type stored by ASM, but additional templates can bedefined as needed.

    Failure groups are defined within a disk group to support the required level of redundancy. Fortwo-way mirroring you would expect a disk group to contain two failure groups so individual files

  • 8/6/2019 Oracle 10g New Features1

    3/26

    are written to two locations.

    In summary ASM provides the following functionality:

    Manages groups of disks, called disk groups.

    Manages disk redundancy within a disk group.

    Provides near-optimal I/O balancing without any manual tuning. Enables management of database objects without specifying mount points and

    filenames. Supports large files.

    4) Automatic Workload Repository (AWR) in Oracle Database 10g

    AWR Features

    The AWR is used to collect performance statistics including:

    Wait events used to identify performance problems.

    Time model statistics indicating the amount of DB time associated with a process fromthe V$SESS_TIME_MODEL and V$SYS_TIME_MODEL views.

    Active Session History (ASH) statistics from the V$ACTIVE_SESSION_HISTORY view.

    Some system and session statistics from the V$SYSSTAT and V$SESSTAT views.

    Object usage statistics.

    Resource intensive SQL statements.

    The repository is a source of information for several other Oracle 10g features including:

    Automatic Database Diagnostic Monitor

    SQL Tuning Advisor Undo Advisor

    Segment Advisor

    Snapshots

    By default snapshots of the relevant data are taken every hour and retained for 7 days. Thedefault values for these settings can be altered using:BEGINDBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings(retention => 43200, -- Minutes (= 30 Days). Current value

    retained if NULL.interval => 30); -- Minutes. Current value retained if

    NULL.END;/

    5) DBMS_FILE_TRANSFER Package in Oracle Database10g

  • 8/6/2019 Oracle 10g New Features1

    4/26

    Oracle 10g has introduced the DBMS_FILE_TRANSFER package which provides an API forcopying binary files between database servers.

    Common Usage Notes

    COPY_FILE

    GET_FILE

    PUT_FILE

    Common Usage Notes

    All of the the currently supported procedures have some common usage notes listed below:

    The user must have read privilege on the source directory object and write privilege onthe destination directory object.

    The procedure converts directory object names to uppercase unless they are surroundedby double quotes.

    Files to be copied must be multiples of 512 bytes in size.

    Files to be copied must be equal to or less than 2 terabytes in size.

    File transfers are not transactional.

    Files are copied as binary, so no character conversions are performed.

    File copies can be monitored using the V$SESSION_LONGOPS view.

    COPY_FILE

    The COPY_FILE procedure allows you to copy binary files from one location to another on thesame server.

    GET_FILE

    The GET_FILE procedure allows you to copy binary files from a remote server to the local server.

    PUT_FILE

    The PUT_FILE procedure allows you to copy binary files from the local server to a remote server.

    6) Flashback New Features and Enhancements in OracleDatabase 10g

    Oracle9i introduced the DBMS_FLASHBACK package to allow queries to reference older versionsof the database. Oracle 10g has taken this technology a step further making it simpler to use andmuch more flexible.

    Note: Internally Oracle uses SCNs to track changes so any flashback operation that uses atimestamp must be translated into the nearest SCN which can result in a 3 second error.

    Flashback Query

    Flashback Version Query

    http://www.oracle-base.com/articles/10g/FileTransfer10g.php#common_usage_notes#common_usage_noteshttp://www.oracle-base.com/articles/10g/FileTransfer10g.php#copy_file#copy_filehttp://www.oracle-base.com/articles/10g/FileTransfer10g.php#get_file#get_filehttp://www.oracle-base.com/articles/10g/FileTransfer10g.php#get_file#get_filehttp://www.oracle-base.com/articles/10g/FileTransfer10g.php#put_file#put_filehttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_query#flashback_queryhttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_version_query#flashback_version_queryhttp://www.oracle-base.com/articles/10g/FileTransfer10g.php#common_usage_notes#common_usage_noteshttp://www.oracle-base.com/articles/10g/FileTransfer10g.php#copy_file#copy_filehttp://www.oracle-base.com/articles/10g/FileTransfer10g.php#get_file#get_filehttp://www.oracle-base.com/articles/10g/FileTransfer10g.php#put_file#put_filehttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_query#flashback_queryhttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_version_query#flashback_version_query
  • 8/6/2019 Oracle 10g New Features1

    5/26

    Flashback Transaction Query

    Flashback Table

    Flashback Drop (Recycle Bin)

    Flashback Database

    Flashback Query Functions

    Flashback Query

    Flashback Query allows the contents of a table to be queried with reference to a specific point intime, using the AS OF clause. Essentially it is the same as the DBMS_FLASHBACK functionalityor Oracle9i, but in a more convenient form. For example:CREATE TABLE flashback_query_test (id NUMBER(10)

    );

    SELECT current_scn, TO_CHAR(SYSTIMESTAMP, 'YYYY-MM-DD HH24:MI:SS') FROMv$database;

    CURRENT_SCN TO_CHAR(SYSTIMESTAM----------- -------------------

    722452 2004-03-29 13:34:12

    Flashback Version Query

    Flashback version query allows the versions of a specific row to be tracked during a specifiedtime period using the VERSIONS BETWEEN clause

    Flashback Transaction Query

    Flashback transaction query can be used to get extra information about the transactions listed by

    flashback version queries. The VERSIONS_XID column values from a flashback version querycan be used to query the FLASHBACK_TRANSACTION_QUERY view like:

    Flashback Table

    The FLASHBACK TABLE command allows point in time recovery of individual tables subject tothe following requirements:

    You must have either the FLASHBACK ANY TABLE system privilege or have FLASHBACKobject privilege on the table.

    You must have SELECT, INSERT, DELETE, and ALTER privileges on the table.

    There must be enough information in the undo tablespace to complete the operation.

    Row movement must be enabled on the table (ALTER TABLE tablename ENABLEROW MOVEMENT;).

    Flashback Drop (Recycle Bin)

    In Oracle 10g the default action of a DROP TABLE command is to move the table to the recyclebin (or rename it), rather than actually dropping it. The PURGE option can be used to permanentlydrop a table.

    http://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_transaction_query#flashback_transaction_queryhttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_table#flashback_tablehttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_drop#flashback_drophttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_drop#flashback_drophttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_database#flashback_databasehttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_query_functions#flashback_query_functionshttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_transaction_query#flashback_transaction_queryhttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_table#flashback_tablehttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_drop#flashback_drophttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_database#flashback_databasehttp://www.oracle-base.com/articles/10g/Flashback10g.php#flashback_query_functions#flashback_query_functions
  • 8/6/2019 Oracle 10g New Features1

    6/26

    The recycle bin is a logical collection of previously dropped objects, with access tied to the DROPprivilege. The contents of the recycle bin can be shown using the SHOW RECYCLEBIN commandand purged using the PURGE TABLE command. As a result, a previously dropped table can berecovered from the recycle bin:

    Flashback Database

    The FLASHBACK DATABASE command is a fast alternative to performing an incomplete recovery.In order to flashback the database you must have SYSDBA privilege and the flash recovery areamust have been prepared in advance.

    If the database is in NOARCHIVELOG it must be switched to ARCHIVELOG mode:CONN sys/password AS SYSDBAALTER SYSTEM SETlog_archive_dest_1='location=d:\oracle\oradata\DB10G\archive\'SCOPE=SPFILE;ALTER SYSTEM SET log_archive_format='ARC%S_%R.%T' SCOPE=SPFILE;ALTER SYSTEM SET log_archive_start=TRUE SCOPE=SPFILE;SHUTDOWN IMMEDIATE

    STARTUP MOUNTARCHIVE LOG STARTALTER DATABASE ARCHIVELOG;ALTER DATABASE OPEN;

    Flashback must be enabled before any flashback operations are performed:CONN sys/password AS SYSDBASHUTDOWN IMMEDIATESTARTUP MOUNT EXCLUSIVEALTER DATABASE FLASHBACK ON;ALTER DATABASE OPEN;

    7) Database Security Enhancements in Oracle Database10g

    Virtual Private Database (VPD) Enhancementso Column-Level VPD Policyo Column Maskingo Policy Typeso Application Context Support for Parallel Queries

    Fine-Grained Auditing Enhancements

    Uniform Audit Trail

    Audit Trail Contents

    DBMS_CRYPTO

    Virtual Private Database (VPD) Enhancements

    Column-Level VPD PolicyIn conventional Virtual Private Database the VPD Policy is applied to the whole row. By default aColumn-Level VPD Policy allows you to restrict the rows displayed only if specified columns areaccessed:

    http://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#vpd#vpdhttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#column_level_vdp_policy#column_level_vdp_policyhttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#column_level_vdp_policy#column_level_vdp_policyhttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#column_masking#column_maskinghttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#column_masking#column_maskinghttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#policy_types#policy_typeshttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#application_context_support_for_parallel_queries#application_context_support_for_parallel_querieshttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#application_context_support_for_parallel_queries#application_context_support_for_parallel_querieshttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#fga#fgahttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#uniform_audit_trail#uniform_audit_trailhttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#audit_trail_contents#audit_trail_contentshttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#audit_trail_contents#audit_trail_contentshttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#dbms_crypto#dbms_cryptohttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#vpd#vpdhttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#column_level_vdp_policy#column_level_vdp_policyhttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#column_masking#column_maskinghttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#policy_types#policy_typeshttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#application_context_support_for_parallel_queries#application_context_support_for_parallel_querieshttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#fga#fgahttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#uniform_audit_trail#uniform_audit_trailhttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#audit_trail_contents#audit_trail_contentshttp://www.oracle-base.com/articles/10g/DatabaseSecurityEnhancements10g.php#dbms_crypto#dbms_crypto
  • 8/6/2019 Oracle 10g New Features1

    7/26

    Fine-Grained Auditing Enhancements

    Fine-grained auditing now includes support for DML statements in addition to queries:

    Uniform Audit Trail

    The DBA_COMMON_AUDIT_TRAIL view has been added to display the complete audit trail:

    DBA_AUDIT_TRAIL - Standard auditing only (from AUD$).

    DBA_FGA_AUDIT_TRAIL - Fine-grained auditing only (from FGA_LOG$).

    DBA_COMMON_AUDIT_TRAIL - Both standard and fine-grained auditing.

    Audit Trail Contents

    Several fields have been added to both the standard and fine-grained audit trails:

    EXTENDED_TIMESTAMP - A more precise value than the exising TIMESTAMP column. PROXY_SESSIONID - Proxy session serial number when an enterprise user is logging in

    via the proxy method. GLOBAL_UID - Global Universal Identifier for an enterprise user.

    INSTANCE_NUMBER - The INSTANCE_NUMBER value from the actioning instance.

    OS_PROCESS - Operating system process id for the oracle process.

    TRANSACTIONID - Transaction identifier for the audited transaction. This column can beused to join to the XID column on the FLASHBACK_TRANSACTION_QUERY view.

    SCN - System change number of the query. This column can be used in flashbackqueries.

    SQL_BIND - The values of any bind variables if any.

    SQL_TEXT - The SQL statement that initiated the audit action.

    The SQL_BIND and SQL_TEXT columns are only populated when theAUDIT_TRAIL=DB_EXTENDED initialization parameter is set:

    DBMS_CRYPTO

    The DBMS_CRYPTO package is a replacement for the DBMS_OBFUSCATION_TOOLKIT packageavailable in Oracle 8i and 9i. The new package is easier to use and contains more cryptographicalgorithms:

    Cryptographic algorithms - DES, 3DES, AES, RC4, 3DES_2KEY

    Padding forms - PKCS5, zeroes Block cipher chaining modes - CBC, CFB, ECB, OFB

    Cryptographic hash algorithms - MD5, SHA-1, MD4

    Keyed hash (MAC) algorithms - HMAC_MD5, HMAC_SH1

    Cryptographic pseudo-random number generator - RAW, NUMBER, BINARY_INTEGER

    Database types - RAW, CLOB, BLOB

  • 8/6/2019 Oracle 10g New Features1

    8/26

    8) MERGE Statement Enhancements in Oracle Database10g

    Oracle 10g includes a number of amendments to the MERGE statement making it more flexible.

    Test Table Optional Clauses

    Conditional Operations

    DELETE Clause

    Test Table

    The following examples use the table defined below.CREATE TABLE test1 ASSELECT *FROM all_objectsWHERE 1=2;

    Optional Clauses

    The MATCHED and NOT MATCHED clauses are now optional making all of the following examplesvalid.-- Both clauses present.MERGE INTO test1 aUSING all_objects bON (a.object_id = b.object_id)

    WHEN MATCHED THENUPDATE SET a.status = b.status

    WHEN NOT MATCHED THENINSERT (object_id, status)VALUES (b.object_id, b.status);

    9) Oracle Data Pump in Oracle Database 10g

    Oracle Data Pump is a newer, faster and more flexible alternative to the "exp" and "imp" utilitiesused in previous Oracle versions. In addition to basic import and export functionality data pumpprovides a PL/SQL API and support for external tables.

    Getting Started

    Table Exports/Imports

    Schema Exports/Imports Database Exports/Imports

    Miscellaneous Information

    Data Pump API

    External Tables

    Help

    Getting Started

    http://www.oracle-base.com/articles/10g/MergeEnhancements10g.php#test_table#test_tablehttp://www.oracle-base.com/articles/10g/MergeEnhancements10g.php#optional_clauses#optional_clauseshttp://www.oracle-base.com/articles/10g/MergeEnhancements10g.php#conditional_operations#conditional_operationshttp://www.oracle-base.com/articles/10g/MergeEnhancements10g.php#delete_clause#delete_clausehttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#GettingStarted#GettingStartedhttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#GettingStarted#GettingStartedhttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#TableExpImp#TableExpImphttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#SchemaExpImp#SchemaExpImphttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#SchemaExpImp#SchemaExpImphttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#DatabaseExpImp#DatabaseExpImphttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#MiscellaneousInformation#MiscellaneousInformationhttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#DataPumpAPI#DataPumpAPIhttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#DataPumpAPI#DataPumpAPIhttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#ExternalTables#ExternalTableshttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#Help#Helphttp://www.oracle-base.com/articles/10g/MergeEnhancements10g.php#test_table#test_tablehttp://www.oracle-base.com/articles/10g/MergeEnhancements10g.php#optional_clauses#optional_clauseshttp://www.oracle-base.com/articles/10g/MergeEnhancements10g.php#conditional_operations#conditional_operationshttp://www.oracle-base.com/articles/10g/MergeEnhancements10g.php#delete_clause#delete_clausehttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#GettingStarted#GettingStartedhttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#TableExpImp#TableExpImphttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#SchemaExpImp#SchemaExpImphttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#DatabaseExpImp#DatabaseExpImphttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#MiscellaneousInformation#MiscellaneousInformationhttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#DataPumpAPI#DataPumpAPIhttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#ExternalTables#ExternalTableshttp://www.oracle-base.com/articles/10g/OracleDataPump10g.php#Help#Help
  • 8/6/2019 Oracle 10g New Features1

    9/26

    For the examples to work we must first unlock the SCOTT account and create a directory object itcan access:CONN sys/password@db10g AS SYSDBAALTER USER scott IDENTIFIED BY tiger ACCOUNT UNLOCK;GRANT CREATE ANY DIRECTORY TO scott;

    CREATE OR REPLACE DIRECTORY test_dir AS '/u01/app/oracle/oradata/';GRANT READ, WRITE ON DIRECTORY test_dir TO scott;

    Table Exports/Imports

    The TABLES parameter is used to specify the tables that are to be exported. The following is anexample of the table export and import syntax:expdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIRdumpfile=EMP_DEPT.dmp logfile=expdpEMP_DEPT.log

    impdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIRdumpfile=EMP_DEPT.dmp logfile=impdpEMP_DEPT.log

    For example output files seeexpdpEMP_DEPT.logand impdpEMP_DEPT.log.

    The TABLE_EXISTS_ACTION=APPEND parameter allows data to be imported into existing tables.

    Schema Exports/Imports

    The OWNER parameter of exp has been replaced by the SCHEMAS parameter which is used tospecify the schemas to be exported. The following is an example of the schema export andimport syntax:expdp scott/tiger@db10g schemas=SCOTT directory=TEST_DIRdumpfile=SCOTT.dmp logfile=expdpSCOTT.log

    impdp scott/tiger@db10g schemas=SCOTT directory=TEST_DIRdumpfile=SCOTT.dmp logfile=impdpSCOTT.log

    10) Upgrading to Oracle Database 10g

    This article provides a brief overview of the areas involved in upgrading existing databases toOracle 10g including:

    Supported Upgrade Paths

    Pre-Upgrade Validation Checks

    Database Upgrade Assistant (DBCA)

    STARTUP UPGRADE

    The whole migration process is beyond the scope of this article so please refer to the Upgradinga Database to the New Oracle Database 10g Releasedocument for further information.

    Supported Upgrade Paths

    http://www.oracle-base.com/articles/10g/expdpEMP_DEPT.loghttp://www.oracle-base.com/articles/10g/expdpEMP_DEPT.loghttp://www.oracle-base.com/articles/10g/expdpEMP_DEPT.loghttp://www.oracle-base.com/articles/10g/impdpEMP_DEPT.loghttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#supported_upgrade_paths#supported_upgrade_pathshttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#pre-upgrade_validation_checks#pre-upgrade_validation_checkshttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#pre-upgrade_validation_checks#pre-upgrade_validation_checkshttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#database_upgrade_assistant#database_upgrade_assistanthttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#startup_upgrade#startup_upgradehttp://download-west.oracle.com/docs/cd/B14117_01/server.101/b10763/upgrade.htmhttp://download-west.oracle.com/docs/cd/B14117_01/server.101/b10763/upgrade.htmhttp://download-west.oracle.com/docs/cd/B14117_01/server.101/b10763/upgrade.htmhttp://www.oracle-base.com/articles/10g/expdpEMP_DEPT.loghttp://www.oracle-base.com/articles/10g/impdpEMP_DEPT.loghttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#supported_upgrade_paths#supported_upgrade_pathshttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#pre-upgrade_validation_checks#pre-upgrade_validation_checkshttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#database_upgrade_assistant#database_upgrade_assistanthttp://www.oracle-base.com/articles/10g/UpgradingTo10g.php#startup_upgrade#startup_upgradehttp://download-west.oracle.com/docs/cd/B14117_01/server.101/b10763/upgrade.htmhttp://download-west.oracle.com/docs/cd/B14117_01/server.101/b10763/upgrade.htm
  • 8/6/2019 Oracle 10g New Features1

    10/26

    Direct upgrades to 10g are possible from existing databases with versions listed in the tablebelow. Upgrades from other versions are supported only via intermediate upgrades to asupported upgrade version.

    Original Version Upgrade Script

    8.0.6 u0800060.sql

    8.1.7 u0801070.sql

    9.0.1 u0900010.sql

    9.2.0 u0902000.sql

    The preferred upgrade method is to use the Database Upgrade Assistant (DBUA), a GUI tool thatperforms all necessary prerequisite checks and operations before upgrading the specifiedinstances. The DBUA can be started directly from the Oracle Universal Installer (OUI) orseparately after the software installation is complete.

    Alternatively you may which to perform a manual upgrade which involves the following steps:

    Analyze the existing instance using the utlu101i.sql script, explained below. Backup the database.

    Start the original database in the new upgrade mode (see below) and proceed with theupgrade. The majority of the upgrade work is done by running the appropriate upgradescript for the current database version.

    Recompile invalid objects.

    Troubleshoot any issues or abort the upgrade.

    Pre-Upgrade Validation Checks

    Oracle 10g includes a script ($ORACLE_HOME/rdbms/admin/utlu101i.sql) which performs pre-update validation checks on an existing instance. The script checks a number of areas to makesure the instance is suitable for upgrade including:

    Database version.

    Log file sizes.

    Tablespace sizes.

    Server options.

    Initialization parameters (updated, depercated and obsolete).

    Database components.

    SYSAUX tablespace present.

    Cluster information.

    Database Upgrade Assistant (DBCA)

    The Database Upgrade Assistant (DBUA) is a GUI tool that guides the user through the wholeupgrade process, including all the steps listed in the manual upgrade process. The assistant isstarted using the dbua command in UNIX and Linux environments or from the Start menu (Start> Programs > Oracle - HOME_NAME > Configuration and Migration Tools > Database UpgradeAssistant) in Windows environments.

    Once the assistant has started it leads the user through the several steps including:

  • 8/6/2019 Oracle 10g New Features1

    11/26

    Selecting the instance to upgrade.

    Analyzing the existing database to make sure it is suitable for upgrade.

    Creating the SYSAUX tablespace which is required for 10g.

    Deciding whether to recompile all invalid objects when the upgrade is complete.

    Selecting a backup option for the database.

    Deciding how the database should be managed (OEM Console or Grid Control) and

    defining the appropriate authentication. Defining the flash recovery area.

    Performing any necessary network configuration.

    Performing the upgrade process.

    Checking the upgrade results.

    Listing the changes in default behaviour between the old and new versionsof thedatabase.

    Completing the upgrade procedure.

    The DBUA can also be started in silent mode provided all the necessary parameters areprovided.

    STARTUP UPGRADE

    The is a new startup mode associated with the upgrade procedure in Oracle 10g.SQL> STARTUP UPGRADE;

    12) Scheduler in Oracle Database 10g

    Oracle 10g includes a comprehensive scheduler (DBMS_SCHEDULER) to replace and extend thefunctionality provided by the DBMS_JOB package. Jobs form the core of the functionality, but there

    are several other components available:

    Programs

    Schedules

    Jobs

    Job Classes

    Windows

    Windows Groups

    Enable, Disable and Attributes

    Programs

    The scheduler allows you to optionally create programs which hold metadata about a task, but noschedule information. A program may related to a PL/SQL block, a stored procedure or an OSexecutable file. Programs are created using the CREATE_PROGRAM procedure:-- Create the test programs.BEGIN-- PL/SQL Block.DBMS_SCHEDULER.create_program (program_name => 'test_plsql_block_prog',program_type => 'PLSQL_BLOCK',

    http://www.oracle-base.com/articles/10g/Scheduler10g.php#programs#programshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#programs#programshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#schedules#scheduleshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#jobs#jobshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#job_classes#job_classeshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#job_classes#job_classeshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#windows#windowshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#window_groups#window_groupshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#enable_disable_and_attributes#enable_disable_and_attributeshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#programs#programshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#schedules#scheduleshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#jobs#jobshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#job_classes#job_classeshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#windows#windowshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#window_groups#window_groupshttp://www.oracle-base.com/articles/10g/Scheduler10g.php#enable_disable_and_attributes#enable_disable_and_attributes
  • 8/6/2019 Oracle 10g New Features1

    12/26

    program_action => 'BEGIN DBMS_STATS.gather_schema_stats(''SCOTT'');END;',

    enabled => TRUE,comments => 'Program to gather SCOTT''s statistics using a

    PL/SQL block.');

    Services in Oracle Database 10g

    In Real Application Cluster (RAC) environments it is sometimes desirable to run applications on asubset of RAC nodes, or have preferred nodes for specific applications. In Oracle 10g this isaccomplished using services.

    Cluster Configuration

    Service Creation

    Jobs and Services

    Connections and Services

    Cluster Configuration

    For services to function correctly the GSD daemon must be running on each node in the cluster.The GSD daemons are started using the gsdctl utility, which is part of the Cluster ReadyServices (CRS) installation, so they must be started from that environment as follows.# Set environment.export ORACLE_HOME=/u01/app/oracle/product/10.1.0/crsexport PATH=$ORACLE_HOME/bin:$PATH

    # Start GSD daemon.gsdctl start

    SQL*Plus Enhancements in Oracle Database 10g

    Whitespace Support in Windows Path and File Names

    Glogin, Login and Predefined Variables

    APPEND, CREATE and REPLACE extensions to SPOOL and SAVE

    SHOW RECYCLEBIN

    Miscellaneous Enhancements

    Whitespace Support in Windows Path and File Names

    Support for whitespaces in file names has been added to the START, @, @@, RUN, SPOOL,SAVE and EDIT commands. Names containing whitespaces must be quoted for them to berecognised correctly:SPOOL "My Report.txt"@"My Report.sql"

    Glogin, Login and Predefined Variables

    http://www.oracle-base.com/articles/10g/Services10g.php#cluster_configuration#cluster_configurationhttp://www.oracle-base.com/articles/10g/Services10g.php#service_creation#service_creationhttp://www.oracle-base.com/articles/10g/Services10g.php#jobs_and_services#jobs_and_serviceshttp://www.oracle-base.com/articles/10g/Services10g.php#connections_and_services#connections_and_serviceshttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#WhitespaceSupport#WhitespaceSupporthttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#GloginLoginPredefinedVariables#GloginLoginPredefinedVariableshttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#GloginLoginPredefinedVariables#GloginLoginPredefinedVariableshttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#APPEND_CREATE_REPLACE_SPOOL_SAVE#APPEND_CREATE_REPLACE_SPOOL_SAVEhttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#SHOWRECYCLEBIN#SHOWRECYCLEBINhttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#MiscellaneousEnhancements#MiscellaneousEnhancementshttp://www.oracle-base.com/articles/10g/Services10g.php#cluster_configuration#cluster_configurationhttp://www.oracle-base.com/articles/10g/Services10g.php#service_creation#service_creationhttp://www.oracle-base.com/articles/10g/Services10g.php#jobs_and_services#jobs_and_serviceshttp://www.oracle-base.com/articles/10g/Services10g.php#connections_and_services#connections_and_serviceshttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#WhitespaceSupport#WhitespaceSupporthttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#GloginLoginPredefinedVariables#GloginLoginPredefinedVariableshttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#APPEND_CREATE_REPLACE_SPOOL_SAVE#APPEND_CREATE_REPLACE_SPOOL_SAVEhttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#SHOWRECYCLEBIN#SHOWRECYCLEBINhttp://www.oracle-base.com/articles/10g/SQLPlusEnhancements10g.php#MiscellaneousEnhancements#MiscellaneousEnhancements
  • 8/6/2019 Oracle 10g New Features1

    13/26

    The user profile files, glogin.sql and login.sql are now run after each successful connection inaddition to SQL*Plus startup. This is particularly useful when the login.sql file is used to set theSQLPROMPT to the current connection details.

    Three new predefined variables have been added to SQL*Plus:

    _DATE - Contains the current date or a user defined fixed string. _PRIVILEGE - Contains privilege level such as AS SYSDBA, AS SYSOPER or blank.

    _USER - Contains the current username (like SHOW USER).

    An example of their use would be:SET SQLPROMPT "_USER'@'_CONNECT_IDENTIFIER _PRIVILEGE _DATE> "

    The values of the variables can be viewed using the DEFINE command with no parameters.

    APPEND, CREATE and REPLACE extensions to SPOOL and SAVE

    The following extentions have been added to the SPOOL and SAVE commands:

    REPLACE - (Default) This option replaces an existing file or creates it if it is not alreadypresent.

    CREATE - This option creates a new file or produces an error if the file already exists.

    APPEND - This option appends to an existing file, or creates a new file if it's not alreadypresent.

  • 8/6/2019 Oracle 10g New Features1

    14/26

    Performance Tuning Enhancements in Oracle Database

    10g

    Oracle 10g includes many performance tuning enhancements including:

    Automatic Performance Diagnostic and Tuning Features

    Automatic Shared Memory Management

    Wait Model Improvements

    Automatic Optimizer Statistics Collection

    Dynamic Sampling

    CPU Costing

    Optimizer Hints

    Rule Based Optimizer Obsolescence Tracing Enhancements

    SAMPLE Clause Enhancements

    Hash Partitioned Global Indexes

    Automatic Performance Diagnostic and Tuning Features

    Oracle 10g includes several features related to automatic performance diagnostics and tuningincluding:

    Automatic Optimizer Statistics Collection- The name says it all.

    Automatic Workload Repository (AWR)- An extended version of the STATSPACK

    repository that is the heart of all the new diagnostics and tuning features. Automatic Database Diagnostic Monitoring (ADDM) - An automatic diagnostics and

    tuning tool which uses the information stored in the AWR. Automatic SQL Tuning Advisor- A built in SQL tuning feature.

    Most of these features are beyond the scope of this article and as such will be dealt with inseparate aticles.

    Automatic Shared Memory Management

    Automatic Shared Memory Management puts Oracle in control of allocating memory within the

    SGA. The SGA_TARGET parameter sets the amount of memory available to the SGA. Thisparameter can be altered dynamically up to a maximum of the SGA_MAX_SIZE parameter value.Provided the STATISTICS_LEVEL is set to TYPICAL orALL and the SGA_TARGET is set to avalue other than "0" Oracle will control the memory pools which would otherwise be controlled bythe following parameters:

    DB_CACHE_SIZE (default block size)

    SHARED_POOL_SIZE

    LARGE_POOL_SIZE

    http://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_performance_diagnostic_and_tuning_features#automatic_performance_diagnostic_and_tuning_featureshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_performance_diagnostic_and_tuning_features#automatic_performance_diagnostic_and_tuning_featureshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_shared_memory_management#automatic_shared_memory_managementhttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_shared_memory_management#automatic_shared_memory_managementhttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#wait_model_improvements#wait_model_improvementshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_optimizer_statistics_collection#automatic_optimizer_statistics_collectionhttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_optimizer_statistics_collection#automatic_optimizer_statistics_collectionhttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#dynamic_sampling#dynamic_samplinghttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#dynamic_sampling#dynamic_samplinghttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#cpu_costing#cpu_costinghttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#optimizer_hints#optimizer_hintshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#optimizer_hints#optimizer_hintshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#rule_based_optimizer_obsolescence#rule_based_optimizer_obsolescencehttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#rule_based_optimizer_obsolescence#rule_based_optimizer_obsolescencehttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#tracing_enhancements#tracing_enhancementshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#tracing_enhancements#tracing_enhancementshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#sample_clause_enhancements#sample_clause_enhancementshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#hash_partitioned_global_indexes#hash_partitioned_global_indexeshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#hash_partitioned_global_indexes#hash_partitioned_global_indexeshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_optimizer_statistics_collection#automatic_optimizer_statistics_collectionhttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_optimizer_statistics_collection#automatic_optimizer_statistics_collectionhttp://www.oracle-base.com/articles/10g/AutomaticWorkloadRepository10g.phphttp://www.oracle-base.com/articles/10g/AutomaticWorkloadRepository10g.phphttp://www.oracle-base.com/articles/10g/AutomaticDatabaseDiagnosticMonitor10g.phphttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.phphttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.phphttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_performance_diagnostic_and_tuning_features#automatic_performance_diagnostic_and_tuning_featureshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_shared_memory_management#automatic_shared_memory_managementhttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#wait_model_improvements#wait_model_improvementshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_optimizer_statistics_collection#automatic_optimizer_statistics_collectionhttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#dynamic_sampling#dynamic_samplinghttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#cpu_costing#cpu_costinghttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#optimizer_hints#optimizer_hintshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#rule_based_optimizer_obsolescence#rule_based_optimizer_obsolescencehttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#tracing_enhancements#tracing_enhancementshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#sample_clause_enhancements#sample_clause_enhancementshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#hash_partitioned_global_indexes#hash_partitioned_global_indexeshttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#automatic_optimizer_statistics_collection#automatic_optimizer_statistics_collectionhttp://www.oracle-base.com/articles/10g/AutomaticWorkloadRepository10g.phphttp://www.oracle-base.com/articles/10g/AutomaticDatabaseDiagnosticMonitor10g.phphttp://www.oracle-base.com/articles/10g/AutomaticSQLTuning10g.php
  • 8/6/2019 Oracle 10g New Features1

    15/26

    JAVA_POOL_SIZE

    If these parameters are set to a non-zero value they represent the minimum size for the pool.These minimum values may be necessary if you experience application errors when certain poolsizes drop below a specific threshold.

    The following parameters must be set manually and take memory from the quota allocated by theSGA_TARGET parameter:

    DB_KEEP_CACHE_SIZE

    DB_RECYCLE_CACHE_SIZE

    DB_nK_CACHE_SIZE (non-default block size)

    STREAMS_POOL_SIZE

    LOG_BUFFER

    Wait Model Improvements

    A number of views have been updated and added to improve the wait model. The updated views

    include:

    V$EVENT_NAME

    V$SESSION

    V$SESSION_WAIT

    The new views include:

    V$ACTIVE_SESSION_HISTORY

    V$SYSTEM_WAIT_HISTORY

    V$SESS_TIME_MODEL

    V$SYS_TIME_MODEL

    V$SYSTEM_WAIT_CLASS

    V$SESSION_WAIT_CLASS

    V$EVENT_HISTOGRAM

    V$FILE_HISTOGRAM

    V$TEMP_HISTOGRAM

    The following are some examples of how these updates can be used.

    The V$EVENT_NAME view has had three new columns added (WAIT_CLASS_ID, WAIT_CLASS#and WAIT_CLASS) which indicate the class of the event. This allows easier aggregation of eventdetails:User I/O .109552

    9 rows selected.

    The V$SESSION view has had several columns added that include blocking session and waitinformation. The wait information means it's no longer necessary to join to V$SESSION_WAIT toget wait information for a session:-- Display blocked session and their blocking session details.SELECT sid, serial#, blocking_session_status, blocking_sessionFROM v$sessionWHERE blocking_session IS NOT NULL;

  • 8/6/2019 Oracle 10g New Features1

    16/26

    no rows selected

    -- Display the resource or event the session is waiting for.SELECT sid, serial#, event, (seconds_in_wait/1000000) seconds_in_waitFROM v$sessionORDER BY sid;

    The V$SYSTEM_WAIT_HISTORY view shows historical wait information which allows you toidentify issues after the session has ended.

    Automatic Optimizer Statistics Collection

    By default Oracle 10g automatically gathers optimizer statistics using a scheduled job calledGATHER_STATS_JOB. By default this job runs within a maintenance windows between 10 P.M. to6 A.M. week nights and all day on weekends. The job calls theDBMS_STATS.GATHER_DATABASE_STATS_JOB_PROC internal procedure which gathersstatistics for tables with either empty or stale statistics, similar to the

    DBMS_STATS.GATHER_DATABASE_STATS procedure using the GATHER AUTO option. The maindifference is that the internal job prioritizes the work such that tables most urgently requiringstatistics updates are processed first.

    In some cases automatically gathering statistics can cause problems. Highly volatile tables andload tables may have their statistics gathered when there is an unrepresentative number of rowspresent. These situations can be avoided by using one of two methods:

    The current statistics can be deleted and locked to prevent DBMS_STATS from gatheringnew statistics. If the OPTIMIZER_DYNAMIC_SAMPLING parameter is set to 2 (thedefault) or higher the necessary statistics will be gathered as part of the queryoptimization stage (See Dynamic Sampling):

    BEGIN

    DBMS_STATS.delete_table_stats('MY_SCHEMA','LOAD_TABLE');

    DBMS_STATS.lock_table_stats('MY_SCHEMA','LOAD_TABLE');

    END;/

    The statistics can be gathered then locked at a time when the table contains theappropriate data:

    BEGIN

    DBMS_STATS.gather_table_stats('MY_SCHEMA','LOAD_TABLE');

    DBMS_STATS.lock_table_stats('MY_SCHEMA','LOAD_TABLE');

    END;

    /System statistics and statistics for fixed object, such as dynamic performance tables, are notgathered automatically.

    Dynamic Sampling

    Dynamic sampling enables the server to improve performance by:

    http://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#dynamic_sampling#dynamic_samplinghttp://www.oracle-base.com/articles/10g/PerformanceTuningEnhancements10g.php#dynamic_sampling#dynamic_sampling
  • 8/6/2019 Oracle 10g New Features1

    17/26

    Estimate single-table predicate selectivities where available statistics are missing or maylead to bad estimations.

    Estimate statatistics for tables and indexes with missing statistics.

    Estimate statatistics for tables and indexes with out of date statistics.

    Dynamic sampling is controled by the OPTIMIZER_DYNAMIC_SAMPLING parameter which

    accepts values from "0" (off) to "10" (agressive sampling) with a default value of "2". At compile-time Oracle determines if dynamic sampling would improve query performance. If so it issuesrecursive statements to estimate the necessary statistics. Dynamic sampling can be beneficialwhen:

    The sample time is small compared to the overall query execution time.

    Dynamic sampling results in a better performing query.

    The query may be executed multiple times.

    In addition to the OPTIMIZER_DYNAMIC_SAMPLING system parameter the dynamic samplinglevel can be set using the DYNAMIC_SAMPLING optimizer hint for specific queries like:SELECT /*+ dynamic_sampling(emp 10) */

    empno, ename, job, salFROM empWHERE deptno = 30;

    The results of dynamic sampling are repeatable provided no rows are inserted, updated ordeleted from the sampled table. The OPTIMIZER_FEATURES_ENABLE parameter will turns offdynamic sampling if it is set to a version earlier than 9.2.0.

    CPU Costing

    By default the cost model for the optimizer is now CPU+I/O, with the cost unit as time.

    Optimizer Hints

    New hints:

    SPREAD_MIN_ANALYSIS - Specifies analysis options for spreadsheets.

    USE_NL_WITH_INDEX - Specifies a nested loops join.

    QB_NAME - Specifies a name for a query block.

    NO_QUERY_TRANSFORMATION - Prevents the optimizer performing querytransformations.

    NO_USE_NL, NO_USE_MERGE, NO_USE_HASH, NO_INDEX_FFS, NO_INDEX_SS andNO_STAR_TRANSFORMATION - Excludes specific operations from the query plan.

    INDEX_SS, INDEX_SS_ASC, INDEX_SS_DESC - Excludes range scans from the queryplan.

    Updated hints:

    Hints that specify table names have been expanded to accept Global Table Hints. Thisallows a base table within a view to be specified using the "view-name.table-name"syntax.

  • 8/6/2019 Oracle 10g New Features1

    18/26

    Hints that specify index names have been expanded to accept Complex Index Hints. Thisallows an index to be specified using the "(table-name.column-name)" syntax instead ofthe index name.

    Some hints can now optionally accept a query block parameter.

    Renamed hints:

    NO_PARALLEL - Formally NOPARALLEL.

    NO_PARALLEL_INDEX - Formally NOPARALLEL_INDEX.

    NO_REWRITE - Formally NOREWRITE.

    Deprecated hints:

    AND_EQUAL

    HASH_AJ

    MERGE_AJ

    NL_AJ

    HASH_SJ

    NL_SJ

    EXPAND_GSET_TO_UNION

    ORDERED_PREDICATES

    ROWID

    STAR

    Rule Based Optimizer Obsolescence

    The Rule Based Optimizer (RBO) is now obsolete in Oracle 10g. The functionality is still presentbut no new functionality has been included in it and it is no longer supported by Oracle. It is onlypresent to provide backwards compatibility during the migration to the query optimizer (CostBased Optimizer). The results of this osolescence are:

    The CHOOSE and RULE options for the OPTIMIZER_MODE parameter still exist but are nolonger supported.

    The default value for the OPTIMIZER_MODE parameter is ALL_ROWS.

    The CHOOSE and RULE optimizer hints still exist but are no longer supported.

    Code requiring the RBO must be migrated to use the query optimizer.

    Tracing Enhancements

    The Oracle Trace functionality has been removed from Oracle 10g. Instead the SQL Trace andTKPROF functionality should be used.

    In multi-tier environments where statements are passed to different sessions by the applicationserver it can become difficult to trace an individual process from start to finish. To solve thisproblem Oracle have introduced End to End Application Tracing which allows a client process tobe identified via the client identifier rather than the typical session id. Each piece of traceinformation is linked to the following information:

    Client Identifier - Specifies the "real" end user. Set using theDBMS_SESSION.SET_IDENTIFIER procedure.

  • 8/6/2019 Oracle 10g New Features1

    19/26

    Service - Specifies a group of related applications. Created using theDBMS_SERVICE.CREATE_SERVICE procedure.

    Module - Specifies a functional area or feature of an application. Set using theDBMS_APPLICATION_INFO.SET_MODULE procedure.

    Action - Specifies the current action (INSERT, UPDATE, DELETE etc.) within the currentmodule. Set using the DBMS_APPLICATION_INFO.SET_ACTION procedure.

    End to end tracing can be managed via Enterprise Manager or a set of APIs and views. Here aresome examples of how to enable and disable to various types of tracing:BEGIN-- Enable/Disable Client Identifier Trace.

    Once the trace files are produced the trcsess command line utility can be used to filter out therelevant data from multiple files. The utility accepts the following parameters:

    OUTPUT - Specifies the name of the consolidated trace file.

    SESSION - Consolidates the file based on the specified session id (SID.SERIAL#columns from V$SESSION).

    CLIENT_ID - Consolidates the file based on the specified client identifier(CLIENT_IDENTIFIER column from V$SESSION).

    SERVICE - Consolidates the file based on the specified service (SERVICE_NAME columnfrom V$SESSION).

    MODULE - Consolidates the file based on the specified module (MODULE column fromV$SESSION).

    ACTION - Consolidates the file based on the specified action (ACTION column fromV$SESSION).

    TRACE_FILES - A space separated list of trace files to be searched. If omitted all files inthe local directory are searched.

    At lease one of the search criteria must be specified. If more than one is specified only trace that

    matches all the criteria is consolidated. Examples oftrcsess usage are:# Search all files for this session.trcsess output=session.trc session=144.2274

    # Search the specified files for this client identifier.trcsess output=client.trc client_id=my_id db10g_ora_198.trcdb10g_ora_206.trc

    # Search the specified files for this service, module and actioncombination.trcsess output=client.trc service=my_service module=my_moduleaction=INSERT db10g_ora_198.trc db10g_ora_206.trc

    Once the consolidated trace file is produced it can be processed by the TKPROF utility like anyother SQL Trace file.

    By default statistics are gathered at the session level. The DBMS_MONITOR package allows this tobe altered to follow the client identifier, service or combinations of the service, module and action:BEGIN

    The gathered statistics can be displayed using the following views:

  • 8/6/2019 Oracle 10g New Features1

    20/26

    DBA_ENABLED_AGGREGATIONS - Accumulated global statistics.

    V$CLIENT_STATS - Accumulated statistics for the specified client identifier.

    V$SERVICE_STATS - Accumulated statistics for the specified service.

    V$SERV_MOD_ACT_STATS - Accumulated statistics for the specified service, module andaction combination.

    V$SVCMETRIC - Accumulated statistics for elapsed time of database calls and CPU

    usage.

    SAMPLE Clause Enhancements

    The SAMPLE clause allows a query to return a limited sample of data by specifying a percentageof rows or blocks to scan. This clause can now be present in complex queries:-- Query 10% or rows.SELECT e.empno, e.ename, d.dnameFROM emp SAMPLE (10) e

    JOIN dept d ON e.deptno = d.deptno;

    -- Query 10% of blocks.SELECT e.empno, e.ename, d.dnameFROM emp SAMPLE BLOCK (10) e

    JOIN dept d ON e.deptno = d.deptno;

    Hash Partitioned Global Indexes

    Support for hash partitioned global indexes has been added in Oracle 10g which can improveperformance when a small number of leaf blocks are experiencing high levels of contention. Thesyntax for creating of a hash paritioned global index is:CREATE INDEX hgidx ON tab (c1,c2,c3) GLOBALPARTITION BY HASH (c1,c2)(PARTITION p1 TABLESPACE tbs_1,PARTITION p2 TABLESPACE tbs_2,

    PARTITION p3 TABLESPACE tbs_3,PARTITION p4 TABLESPACE tbs_4);

    PL/SQL Enhancements in Oracle Database 10g

    Oracle 10g includes many PL/SQL enhancements including:

    PL/SQL Native Compilation

    FORALL Support for Non-Consecutive Indexes

    New IEEE Floating-Point Types

    Improved Overloading With Numeric Types

    Nested Table Enhancements

    Compile-Time Warnings

    Quoting Mechanism for String Literals

    Implicit Conversion Between CLOB and NCLOB

    Regular Expressions

    Flashback Query Functions

    UTL_COMPRESS

    http://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#plsql_native_compilation#plsql_native_compilationhttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#plsql_native_compilation#plsql_native_compilationhttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#forall_support_for_non_consecutive_indexes#forall_support_for_non_consecutive_indexeshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#new_ieee_floating_point_types#new_ieee_floating_point_typeshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#new_ieee_floating_point_types#new_ieee_floating_point_typeshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#improved_overloading_with_numeric_types#improved_overloading_with_numeric_typeshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#improved_overloading_with_numeric_types#improved_overloading_with_numeric_typeshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#nested_table_enhancements#nested_table_enhancementshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#compile_time_warnings#compile_time_warningshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#compile_time_warnings#compile_time_warningshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#quoting_mechanism_for_string_literals#quoting_mechanism_for_string_literalshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#quoting_mechanism_for_string_literals#quoting_mechanism_for_string_literalshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#implicit_conversion_between_clob_and_nclob#implicit_conversion_between_clob_and_nclobhttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#regular_expressions#regular_expressionshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#regular_expressions#regular_expressionshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#flashback_query_functions#flashback_query_functionshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#UTL_COMPRESS#UTL_COMPRESShttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#plsql_native_compilation#plsql_native_compilationhttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#forall_support_for_non_consecutive_indexes#forall_support_for_non_consecutive_indexeshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#new_ieee_floating_point_types#new_ieee_floating_point_typeshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#improved_overloading_with_numeric_types#improved_overloading_with_numeric_typeshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#nested_table_enhancements#nested_table_enhancementshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#compile_time_warnings#compile_time_warningshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#quoting_mechanism_for_string_literals#quoting_mechanism_for_string_literalshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#implicit_conversion_between_clob_and_nclob#implicit_conversion_between_clob_and_nclobhttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#regular_expressions#regular_expressionshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#flashback_query_functions#flashback_query_functionshttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#UTL_COMPRESS#UTL_COMPRESS
  • 8/6/2019 Oracle 10g New Features1

    21/26

    UTL_MAIL

    PL/SQL Native Compilation

    The process of PL/SQL native compilation has been simplified in Oracle 10g. The compiledshared libraries are now stored in the database and extracted as necessary. This means they

    form part of the normal backup and recovery process, require no manual maintenance and areavailable in Real Application Cluster (RAC) configurations. Native compliation of the packagespecification and body are independant of each other, meaning either one, the other or both canbe natively compiled.

    The PLSQL_NATIVE_LIBRARY_DIR parameter is the only one which must be set to use nativecompilation. All other parameters have been obsoleted. The associated compiler commands arestored in the $ORACLE_HOME/plsql/spnc_commands file which should not need to bemodified.

    Native compilation is switched on and off using the PLSQL_CODE_TYPE parameter which can beset at instance and session level using the ALTER SYSTEM and ALTER SESSION commandsrespectively. The following is an example of native PL/SQL compilation:-- Set the PLSQL_NATIVE_LIBRARY_DIR parameter.CONN / AS SYSDBAALTER SYSTEM SET PLSQL_NATIVE_LIBRARY_DIR='/u01/app/oracle/native/'SCOPE=SPFILE;SHUTDOWN IMMEDIATESTARTUP

    -- Switch on native compilation and compile a procedure.CONN scott/tigerALTER SESSION SET PLSQL_CODE_TYPE='NATIVE';

    CREATE OR REPLACE PROCEDURE test_speed ASv_number NUMBER;

    BEGINFOR i IN 1 .. 10000000 LOOPv_number := i / 1000;

    END LOOP;END;/

    SET TIMING ONEXEC test_speed;

    PL/SQL procedure successfully completed.

    Elapsed: 00:00:07.19

    -- Switch off native compilation and recompile the procedure.ALTER SESSION SET PLSQL_CODE_TYPE='INTERPRETED';ALTER PROCEDURE test_speed COMPILE;EXEC test_speed;

    PL/SQL procedure successfully completed.

    Elapsed: 00:00:08.03

    http://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#UTL_MAIL#UTL_MAILhttp://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#UTL_MAIL#UTL_MAIL
  • 8/6/2019 Oracle 10g New Features1

    22/26

  • 8/6/2019 Oracle 10g New Features1

    23/26

    CREATE OR REPLACE PACKAGE BODY numeric_overload_test ASPROCEDURE go (p_number NUMBER) ASBEGINDBMS_OUTPUT.put_line('Using NUMBER');

    END;

    PROCEDURE go (p_number BINARY_FLOAT) ASBEGINDBMS_OUTPUT.put_line('Using BINARY_FLOAT');

    END;

    PROCEDURE go (p_number BINARY_DOUBLE) ASBEGINDBMS_OUTPUT.put_line('Using BINARY_DOUBLE');

    END;END;/

    -- Test it.SET SERVEROUTPUT ON

    BEGINnumeric_overload_test.go(10);numeric_overload_test.go(10.1f);numeric_overload_test.go(10.1d);

    END;/

    It is important to check that the correct overload is being used at all times. The appropriate suffixor conversion function will make the engine to pick the correct overload.

    Nested Table Enhancements

    Nested tables in PL/SQL now support more operations than before. Collections can be assigned

    directly to the value of another collection of the same type, or to the result of a set expression:SET SERVEROUTPUT ONDECLARETYPE t_colors IS TABLE OF VARCHAR2(10);l_col_1 t_colors := t_colors('Red', 'Green', 'Blue');l_col_2 t_colors := t_colors('Red', 'Green', 'Yellow');l_col_3 t_colors;

    PROCEDURE display (p_text IN VARCHAR2,p_col IN t_colors) IS

    BEGINDBMS_OUTPUT.put_line(CHR(10) || p_text);FOR i IN p_col.first .. p_col.last LOOP

    DBMS_OUTPUT.put_line(p_col(i));END LOOP;END;

    BEGIN-- Basic assignment.l_col_3 := l_col_1;display('Direct Assignment:', l_col_3);

    -- Expression assignments.l_col_3 := l_col_1 MULTISET UNION l_col_2;

  • 8/6/2019 Oracle 10g New Features1

    24/26

    display('MULTISET UNION:', l_col_3);

    l_col_3 := l_col_1 MULTISET UNION DISTINCT l_col_2;display('MULTISET UNION DISTINCT:', l_col_3);

    l_col_3 := l_col_1 MULTISET INTERSECT l_col_2;display('MULTISET INTERSECT:', l_col_3);

    l_col_3 := l_col_1 MULTISET INTERSECT DISTINCT l_col_2;display('MULTISET INTERSECT DISTINCT:', l_col_3);

    l_col_3 := l_col_1 MULTISET EXCEPT l_col_2;display('MULTISET EXCEPT:', l_col_3);

    l_col_3 := l_col_1 MULTISET EXCEPT DISTINCT l_col_2;display('MULTISET EXCEPT DISTINCT:', l_col_3);

    END;/

    Compile-Time Warnings

    Oracle can now produce compile-time warnings when code is ambiguous or inefficient be settingthe PLSQL_WARNINGS parameter at either instance or session level. The categories ALL,SEVERE, INFORMATIONAL and PERFORMANCE can be used to alter the type of warnings thatare produced. Examples of their usage include:-- Instance and session level.ALTER SYSTEM SET PLSQL_WARNINGS='ENABLE:ALL';ALTER SESSION SET PLSQL_WARNINGS='DISABLE:PERFORMANCE';

    Quoting Mechanism for String Literals

    Oracle 10g allows you to define your own string delimiters to remove the need to double up anysingle quotes. Any character that is not present in the string can be used as the delimeter:SET SERVEROUTPUT ONBEGIN-- Orginal syntax.DBMS_OUTPUT.put_line('This is Tim''s string!');

    -- New syntax.DBMS_OUTPUT.put_line(q'#This is Tim's string!#');DBMS_OUTPUT.put_line(q'[This is Tim's string!]');

    END;/

    This is Tim's string!This is Tim's string!This is Tim's string!PL/SQL procedure successfully completed.

    Implicit Conversion Between CLOB and NCLOB

  • 8/6/2019 Oracle 10g New Features1

    25/26

    Oracle 10g now supports implicit conversions between CLOBs and NCLOBs and vice-versa. Aswith all type conversions it is still better to be explicit and use the conversion functions TO_CLOBand TO_NCLOB for clarity.

    Regular Expressions

    Oracle 10g supports regular expressions in SQL and PL/SQL with the following functions:

    REGEXP_INSTR - Similar to INSTR except it uses a regular expression rather than aliteral as the search string.

    REGEXP_LIKE - Similar to LIKE except it uses a regular expression as the search string.

    REGEXP_REPLACE - Similar to REPLACE except it uses a regular expression as thesearch string.

    REGEXP_SUBSTR - Returns the string matching the regular expression. Not really similarto SUBSTR.

    /

    Building regular expressions to match your requirements can get a little confusing and this isbeyond the scope of this article.

    Flashback Query Functions

    The TIMESTAMP_TO_SCN and SCN_TO_TIMESTAMP functions have been added to SQL andPL/SQL to simplify flashback operations:SELECT *FROM emp AS OF SCN TIMESTAMP_TO_SCN(SYSTIMESTAMP - 1/24);

    SELECT *

    FROM emp AS OF TIMESTAMP SCN_TO_TIMESTAMP(993240);

    DECLAREl_scn NUMBER;l_timestamp TIMESTAMP;

    BEGINl_scn := TIMESTAMP_TO_SCN(SYSTIMESTAMP - 1/24);l_timestamp := SCN_TO_TIMESTAMP(l_scn);

    END;/

    UTL_COMPRESS

    The UTL_COMPRESS package provides an API to allow compression and decompression ofbinary data (RAW, BLOB and BFILE). It uses the Lempel-Ziv compression algorithm which isequivalent to functionality of the gzip utility. A simple example of it's usage would be:/

    UTL_MAIL

    The UTL_MAIL package provides a simple API to allow email to be sent from PL/SQL. In priorversions this was possible using the UTL_SMTP package, but this required knowledge of the

  • 8/6/2019 Oracle 10g New Features1

    26/26

    SMTP protocol.

    The package is loaded by running the following scripts:CONN sys/password AS SYSDBA@$ORACLE_HOME/rdbms/admin/utlmail.sql@$ORACLE_HOME/rdbms/admin/prvtmail.plb

    In addition the SMTP_OUT_SERVER parameter must be set to identify the SMTP server:CONN sys/password AS SYSDBAALTER SYSTEM SET smtp_out_server='smtp.domain.com' SCOPE=SPFILE;SHUTDOWN IMMEDIATESTARTUP

    With the configuration complete we can now send a mail using:BEGINUTL_MAIL.send(sender => '[email protected]',

    recipients => '[email protected],[email protected]',cc => '[email protected]',bcc => '[email protected]',subject => 'UTL_MAIL Test',message => 'If you get this message it worked!');

    END;

    /The package also supports sending mails with RAW and VARCHAR2 attachments.