Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
• 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 very
short time. As a result it may not always be able to obtain enough information to make the best
decision. Oracle 10g allows the optimizer to run in tuning mode where it can gather additional
information and make recommendations about how specific statements can be tuned further. This
process may take several minutes for a single statement so it is intended to be used on high-load
resource-intensive statements.
• Statistics Analysis - The optimizer recommends the gathering of statistics on objects with
missing or stale statistics. Additional statistics for these objects are stored in an SQL
profile.
• Access Path Analysis - The optimizer investigates the effect of new or modified indexes
on the access path. It's index recommendations relate to a specific statement so where
necessary it will also suggest the use of the SQL Access Advisor to check the impact of
these indexes on a representative SQL workload.
• SQL Structure Analysis - The optimizer suggests alternatives for SQL statements that
contain structures that may impact on performance. The implementation of these
suggestions requires human intervention to check their validity.
The automatic SQL tuning features are accessible from Enterprise Manager on the "Advisor
Central" page these or from PL/SQL using the DBMS_SQLTUNE package. This article will focus on
the PL/SQL API as the Enterprise Manager interface is reasonably intuative.
SQL Tuning Advisor
In order to access the SQL tuning advisor API a user must be granted the ADVISOR privilege:
CONN sys/password AS SYSDBA
GRANT ADVISOR TO scott;
CONN scott/tiger
2) Overview
The Automatic Database Diagnostic Monitor (ADDM) analyzes data in the Automatic Workload
Repository (AWR) to identify potential performance bottlenecks. For each of the identified issues
it locates the root cause and provides recommendations for correcting the problem. An ADDM
analysis task is performed and its findings and recommendations stored in the database every
time an AWR snapshot is taken provided the STATISTICS_LEVEL parameter is set to TYPICAL
or ALL. 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
The ASM functionality is controlled by an ASM instance. This is not a full database instance, just
the 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 disks
that are controlled as a single unit. The physical disks are known as ASM disks, while the files
that 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 of
reference.
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 be
defined as needed.
Failure groups are defined within a disk group to support the required level of redundancy. For
two-way mirroring you would expect a disk group to contain two failure groups so individual files
are written to two locations.
AWR Features
The repository is a source of information for several other Oracle 10g features including:
Snapshots
By default snapshots of the relevant data are taken every hour and retained for 7 days. The
default values for these settings can be altered using:
BEGIN
DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings(
retention => 43200, -- Minutes (= 30 Days). Current value
retained if NULL.
interval => 30); -- Minutes. Current value retained if
NULL.
END;
/
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 on
the destination directory object.
• The procedure converts directory object names to uppercase unless they are surrounded
by 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 the
same 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.
Note: Internally Oracle uses SCNs to track changes so any flashback operation that uses a
timestamp must be translated into the nearest SCN which can result in a 3 second error.
• Flashback Query
• Flashback Version Query
• 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 in
time, using the AS OF clause. Essentially it is the same as the DBMS_FLASHBACK functionality
or Oracle9i, but in a more convenient form. For example:
CREATE TABLE flashback_query_test (
id NUMBER(10)
);
CURRENT_SCN TO_CHAR(SYSTIMESTAM
----------- -------------------
722452 2004-03-29 13:34:12
Flashback version query allows the versions of a specific row to be tracked during a specified
time period using the VERSIONS BETWEEN clause
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 query
can 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 to
the following requirements:
• You must have either the FLASHBACK ANY TABLE system privilege or have FLASHBACK
object 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 ENABLE
ROW MOVEMENT;).
In Oracle 10g the default action of a DROP TABLE command is to move the table to the recycle
bin (or rename it), rather than actually dropping it. The PURGE option can be used to permanently
drop a table.
The recycle bin is a logical collection of previously dropped objects, with access tied to the DROP
privilege. The contents of the recycle bin can be shown using the SHOW RECYCLEBIN command
and purged using the PURGE TABLE command. As a result, a previously dropped table can be
recovered from the recycle bin:
Flashback Database
Fine-grained auditing now includes support for DML statements in addition to queries:
The DBA_COMMON_AUDIT_TRAIL view has been added to display the complete audit trail:
Several fields have been added to both the standard and fine-grained audit trails:
The SQL_BIND and SQL_TEXT columns are only populated when the
AUDIT_TRAIL=DB_EXTENDED initialization parameter is set:
DBMS_CRYPTO
• Test Table
• Optional Clauses
• Conditional Operations
• DELETE Clause
Test Table
Optional Clauses
The MATCHED and NOT MATCHED clauses are now optional making all of the following examples
valid.
-- Both clauses present.
MERGE INTO test1 a
USING all_objects b
ON (a.object_id = b.object_id)
WHEN MATCHED THEN
UPDATE SET a.status = b.status
WHEN NOT MATCHED THEN
INSERT (object_id, status)
VALUES (b.object_id, b.status);
• Getting Started
• Table Exports/Imports
• Schema Exports/Imports
• Database Exports/Imports
• Miscellaneous Information
• Data Pump API
• External Tables
• Help
Getting Started
For the examples to work we must first unlock the SCOTT account and create a directory object it
can access:
CONN sys/password@db10g AS SYSDBA
ALTER USER scott IDENTIFIED BY tiger ACCOUNT UNLOCK;
GRANT CREATE ANY DIRECTORY TO scott;
Table Exports/Imports
The TABLES parameter is used to specify the tables that are to be exported. The following is an
example of the table export and import syntax:
expdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIR
dumpfile=EMP_DEPT.dmp logfile=expdpEMP_DEPT.log
Schema Exports/Imports
The OWNER parameter of exp has been replaced by the SCHEMAS parameter which is used to
specify the schemas to be exported. The following is an example of the schema export and
import syntax:
expdp scott/tiger@db10g schemas=SCOTT directory=TEST_DIR
dumpfile=SCOTT.dmp logfile=expdpSCOTT.log
The whole migration process is beyond the scope of this article so please refer to the Upgrading
a Database to the New Oracle Database 10g Release document for further information.
The preferred upgrade method is to use the Database Upgrade Assistant (DBUA), a GUI tool that
performs all necessary prerequisite checks and operations before upgrading the specified
instances. The DBUA can be started directly from the Oracle Universal Installer (OUI) or
separately 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 the
upgrade. The majority of the upgrade work is done by running the appropriate upgrade
script for the current database version.
• Recompile invalid objects.
• Troubleshoot any issues or abort the upgrade.
• Database version.
• Log file sizes.
• Tablespace sizes.
• Server options.
• Initialization parameters (updated, depercated and obsolete).
• Database components.
• SYSAUX tablespace present.
• Cluster information.
The Database Upgrade Assistant (DBUA) is a GUI tool that guides the user through the whole
upgrade process, including all the steps listed in the manual upgrade process. The assistant is
started using the dbua command in UNIX and Linux environments or from the Start menu (Start
> Programs > Oracle - HOME_NAME > Configuration and Migration Tools > Database Upgrade
Assistant) in Windows environments.
Once the assistant has started it leads the user through the several steps including:
• 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 the
database.
• Completing the upgrade procedure.
The DBUA can also be started in silent mode provided all the necessary parameters are
provided.
STARTUP UPGRADE
The is a new startup mode associated with the upgrade procedure in Oracle 10g.
SQL> STARTUP UPGRADE;
• 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 no
schedule information. A program may related to a PL/SQL block, a stored procedure or an OS
executable 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',
program_action => 'BEGIN DBMS_STATS.gather_schema_stats(''SCOTT'');
END;',
enabled => TRUE,
comments => 'Program to gather SCOTT''s statistics using a
PL/SQL block.');
• 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 Ready
Services (CRS) installation, so they must be started from that environment as follows.
# Set environment.
export ORACLE_HOME=/u01/app/oracle/product/10.1.0/crs
export PATH=$ORACLE_HOME/bin:$PATH
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 be
recognised correctly:
SPOOL "My Report.txt"
@"My Report.sql"
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 already
present.
• 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 already
present.
Performance Tuning Enhancements in Oracle Database
10g
Oracle 10g includes many performance tuning enhancements including:
Oracle 10g includes several features related to automatic performance diagnostics and tuning
including:
Most of these features are beyond the scope of this article and as such will be dealt with in
separate aticles.
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. This
parameter can be altered dynamically up to a maximum of the SGA_MAX_SIZE parameter value.
Provided the STATISTICS_LEVEL is set to TYPICAL or ALL and the SGA_TARGET is set to a
value other than "0" Oracle will control the memory pools which would otherwise be controlled by
the following parameters:
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 pool
sizes drop below a specific threshold.
The following parameters must be set manually and take memory from the quota allocated by the
SGA_TARGET parameter:
• DB_KEEP_CACHE_SIZE
• DB_RECYCLE_CACHE_SIZE
• DB_nK_CACHE_SIZE (non-default block size)
• STREAMS_POOL_SIZE
• LOG_BUFFER
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
• 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 event
details:
User I/O .109552
9 rows selected.
The V$SESSION view has had several columns added that include blocking session and wait
information. The wait information means it's no longer necessary to join to V$SESSION_WAIT to
get wait information for a session:
-- Display blocked session and their blocking session details.
SELECT sid, serial#, blocking_session_status, blocking_session
FROM v$session
WHERE blocking_session IS NOT NULL;
no rows selected
The V$SYSTEM_WAIT_HISTORY view shows historical wait information which allows you to
identify issues after the session has ended.
By default Oracle 10g automatically gathers optimizer statistics using a scheduled job called
GATHER_STATS_JOB. By default this job runs within a maintenance windows between 10 P.M. to
6 A.M. week nights and all day on weekends. The job calls the
DBMS_STATS.GATHER_DATABASE_STATS_JOB_PROC internal procedure which gathers
statistics for tables with either empty or stale statistics, similar to the
DBMS_STATS.GATHER_DATABASE_STATS procedure using the GATHER AUTO option. The main
difference is that the internal job prioritizes the work such that tables most urgently requiring
statistics updates are processed first.
In some cases automatically gathering statistics can cause problems. Highly volatile tables and
load tables may have their statistics gathered when there is an unrepresentative number of rows
present. These situations can be avoided by using one of two methods:
• The current statistics can be deleted and locked to prevent DBMS_STATS from gathering
new statistics. If the OPTIMIZER_DYNAMIC_SAMPLING parameter is set to 2 (the
default) or higher the necessary statistics will be gathered as part of the query
optimization 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 the
appropriate 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 not
gathered automatically.
Dynamic Sampling
• 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.
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:
Updated hints:
• Hints that specify table names have been expanded to accept Global Table Hints. This
allows a base table within a view to be specified using the "view-name.table-name"
syntax.
• Hints that specify index names have been expanded to accept Complex Index Hints. This
allows an index to be specified using the "(table-name.column-name)" syntax instead of
the index name.
• Some hints can now optionally accept a query block parameter.
Renamed hints:
Deprecated hints:
• AND_EQUAL
• HASH_AJ
• MERGE_AJ
• NL_AJ
• HASH_SJ
• NL_SJ
• EXPAND_GSET_TO_UNION
• ORDERED_PREDICATES
• ROWID
• STAR
The Rule Based Optimizer (RBO) is now obsolete in Oracle 10g. The functionality is still present
but no new functionality has been included in it and it is no longer supported by Oracle. It is only
present to provide backwards compatibility during the migration to the query optimizer (Cost
Based Optimizer). The results of this osolescence are:
• The CHOOSE and RULE options for the OPTIMIZER_MODE parameter still exist but are no
longer 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 and
TKPROF functionality should be used.
In multi-tier environments where statements are passed to different sessions by the application
server it can become difficult to trace an individual process from start to finish. To solve this
problem Oracle have introduced End to End Application Tracing which allows a client process to
be identified via the client identifier rather than the typical session id. Each piece of trace
information is linked to the following information:
• Client Identifier - Specifies the "real" end user. Set using the
DBMS_SESSION.SET_IDENTIFIER procedure.
• Service - Specifies a group of related applications. Created using the
DBMS_SERVICE.CREATE_SERVICE procedure.
• Module - Specifies a functional area or feature of an application. Set using the
DBMS_APPLICATION_INFO.SET_MODULE procedure.
• Action - Specifies the current action (INSERT, UPDATE, DELETE etc.) within the current
module. 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 are
some 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 the
relevant data from multiple files. The utility accepts the following parameters:
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 of trcsess usage are:
# Search all files for this session.
trcsess output=session.trc session=144.2274
# Search the specified files for this service, module and action
combination.
trcsess output=client.trc service=my_service module=my_module
action=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 any
other SQL Trace file.
By default statistics are gathered at the session level. The DBMS_MONITOR package allows this to
be altered to follow the client identifier, service or combinations of the service, module and action:
BEGIN
The SAMPLE clause allows a query to return a limited sample of data by specifying a percentage
of rows or blocks to scan. This clause can now be present in complex queries:
-- Query 10% or rows.
SELECT e.empno, e.ename, d.dname
FROM emp SAMPLE (10) e
JOIN dept d ON e.deptno = d.deptno;
Support for hash partitioned global indexes has been added in Oracle 10g which can improve
performance when a small number of leaf blocks are experiencing high levels of contention. The
syntax for creating of a hash paritioned global index is:
CREATE INDEX hgidx ON tab (c1,c2,c3) GLOBAL
PARTITION BY HASH (c1,c2)
(PARTITION p1 TABLESPACE tbs_1,
PARTITION p2 TABLESPACE tbs_2,
PARTITION p3 TABLESPACE tbs_3,
PARTITION p4 TABLESPACE tbs_4);
The process of PL/SQL native compilation has been simplified in Oracle 10g. The compiled
shared 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 are
available in Real Application Cluster (RAC) configurations. Native compliation of the package
specification and body are independant of each other, meaning either one, the other or both can
be natively compiled.
The PLSQL_NATIVE_LIBRARY_DIR parameter is the only one which must be set to use native
compilation. All other parameters have been obsoleted. The associated compiler commands are
stored in the $ORACLE_HOME/plsql/spnc_commands file which should not need to be
modified.
Native compilation is switched on and off using the PLSQL_CODE_TYPE parameter which can be
set at instance and session level using the ALTER SYSTEM and ALTER SESSION commands
respectively. The following is an example of native PL/SQL compilation:
-- Set the PLSQL_NATIVE_LIBRARY_DIR parameter.
CONN / AS SYSDBA
ALTER SYSTEM SET PLSQL_NATIVE_LIBRARY_DIR='/u01/app/oracle/native/'
SCOPE=SPFILE;
SHUTDOWN IMMEDIATE
STARTUP
SET TIMING ON
EXEC test_speed;
Elapsed: 00:00:07.19
Elapsed: 00:00:08.03
-- Clean up.
DROP PROCEDURE test_speed;
Oracle 10g introduces support for the FORALL syntax with non-consecutive indexes in collections.
The INDICES OF clause allows the FORALL syntax to be used with sparse collections, while the
VALUE OF clause is used for collections of indexes pointing to other collections. The following are
examples of their usage:
/
Oracle 10g introduces the new IEEE floating-point types BINARY_FLOAT and BINARY_DOUBLE.
The types are extremely efficient for heavy floating point computations as the work is passed
directly to the operating system. Literal assignments can be perfomed using the "f" and "d"
suffixes or conversion functions TO_BINARY_FLOAT and TO_BINARY_DOUBLE:
DECLARE
l_binary_float BINARY_FLOAT;
l_binary_double BINARY_DOUBLE;
BEGIN
l_binary_float := 1.1f;
l_binary_double := 1.00001d;
l_binary_float := TO_BINARY_FLOAT(1.1);
l_binary_double := TO_BINARY_DOUBLE(1.00001);
END;
/
Rather than raise exceptions, the resulting values of computations may equate to the following
constants that can be tested for:
• [BINARY_FLOAT|BINARY_DOUBLE]_NAN
• [BINARY_FLOAT|BINARY_DOUBLE]_INFINITY
• [BINARY_FLOAT|BINARY_DOUBLE]_MAX_NORMAL
• [BINARY_FLOAT|BINARY_DOUBLE]_MIN_NORMAL
• [BINARY_FLOAT|BINARY_DOUBLE]_MAX_SUBNORMAL
• [BINARY_FLOAT|BINARY_DOUBLE]_MIN_SUBNORMAL
The constants for NaN and infinity are also available in SQL.
-- Test it.
SET SERVEROUTPUT ON
BEGIN
numeric_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 suffix
or conversion function will make the engine to pick the correct overload.
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 ON
DECLARE
TYPE 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;
-- Expression assignments.
l_col_3 := l_col_1 MULTISET UNION l_col_2;
display('MULTISET UNION:', l_col_3);
Compile-Time Warnings
Oracle can now produce compile-time warnings when code is ambiguous or inefficient be setting
the 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 that
are produced. Examples of their usage include:
-- Instance and session level.
ALTER SYSTEM SET PLSQL_WARNINGS='ENABLE:ALL';
ALTER SESSION SET PLSQL_WARNINGS='DISABLE:PERFORMANCE';
Oracle 10g allows you to define your own string delimiters to remove the need to double up any
single quotes. Any character that is not present in the string can be used as the delimeter:
SET SERVEROUTPUT ON
BEGIN
-- 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;
/
Regular Expressions
Oracle 10g supports regular expressions in SQL and PL/SQL with the following functions:
/
Building regular expressions to match your requirements can get a little confusing and this is
beyond the scope of this article.
The TIMESTAMP_TO_SCN and SCN_TO_TIMESTAMP functions have been added to SQL and
PL/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);
DECLARE
l_scn NUMBER;
l_timestamp TIMESTAMP;
BEGIN
l_scn := TIMESTAMP_TO_SCN(SYSTIMESTAMP - 1/24);
l_timestamp := SCN_TO_TIMESTAMP(l_scn);
END;
/
UTL_COMPRESS
UTL_MAIL
The UTL_MAIL package provides a simple API to allow email to be sent from PL/SQL. In prior
versions this was possible using the UTL_SMTP package, but this required knowledge of the
SMTP protocol.