Call webservice from oracle database

Database Web Service

Note:

The purpose of this article is to provide a step-by-step instruction on how to install the DBWS Callout Utilities on Oracle Database Server 11g and how to verify that it works properly.

All of these environments may be placed on different machines. Anyway, it has been found convenient to have these environments on one machine for an initial installation and test of the DBWS Callout Utilities. This does rule out network problems from affecting the proper operation of the DBWS Callout Utilities.

11g Database Webservice Callout Steps

preparing the Oracle Client and Oracle Database Server

  1. Setup the appropriate environment for the Oracle Client

ORACLE_HOME = D:\app\database\product\11.2.0\dbhome_1
PATH = %PATH%;%ORACLE_HOME%\bin;%ORACLE_HOME%\jdk\bin

  1. Install 11g Release 2 (11.2) for Microsoft Windows (32-Bit) with Installation Type “Administrator”

This will install all the tools and jars required to work with the DBWS Callout Utilities.

  1. Drop The Package “UTL_DBWS” in Schema “SYS”. If existed

drop package UTL_DBWS;

  1. Check the OracleJVM for Invalid Classes

The schema “SYS” and the schema into which the DBWS Callout Utilities should be installed must not have invalid classes. The status of all the java classes installed on the Oracle Database Server instance can be checked as SYSDBA with following SQL statement:

SELECT owner, status, count(*) FROM DBA_OBJECTS
WHERE OBJECT_TYPE=’JAVA CLASS’
GROUP BY owner, status;

For a standard installation of Oracle Database Server 11.1 this SQL statement should return about 20000 valid classes for the owner/schema “SYS”.

It is very difficult to resolve invalid classes once they are in schema “SYS”. There is a huge number of classes in this schema and it is not easy to find out the dependencies. It is a lot easier to resolve invalid classes in schemas that are not system schemas of the Oracle Database Server, because in this case all uploaded jar files and classes with their dependencies should be known to the user. Re-compile all invalid classes( take maximum 100 ) in one compile.

The complete initialization of the OracleJVM is usually the most efficient approach to resolve problems with invalid classes in schema “SYS”, even though this is a risky and time consuming procedure.

  1. Configure the OracleJVM

Preparing the database consists mainly in loading the Web Services client stack into the database. Loading the client stack requires extra Java space inside the OracleJVM to resolve and store load jar files. Make sure the initialization parameters SHARED_POOL_SIZE and JAVA_POOL_SIZE are equal to or greater than 132M and 80M, i.e. or more

shared_pool_size=132M
java_pool_size=80M

Depending on the number of Java classes already loaded into the database, the two parameters may need to be increased beyond 132M and 80M.

In SQL*Plus you can check the size of this initialization parameters as SYSDBA:

show parameter SHARED_POOL_SIZE
show parameter JAVA_POOL_SIZE

alter system set SHARED_POOL_SIZE=132M scope=both;
alter system set JAVA_POOL_SIZE=80M scope=both;

  1. Download the Oracle DBWS Callout Utility 10.1.3.1: this with work with Oracle Database 10g & 11g both.
  2. Take a backup of %Oracle_Home%\sqlj\   folder first:
  3. Unzip the Content of the ZIP File to $ORACLE_HOME (Oracle Database Server Environment)

Unzip in %Oracle_Home%\sqlj\  dbws-callout-utility-10131.zip

  1. Modify the CLASSPATH in Clients_Home\ sqlj\bin\jpub

D:\dbhome_2\product\11.2.0\client_1\bin;D:\app\database\product\11.2.0\dbhome_2;D:\app\database\product\11.2.0\dbhome_1\bin;D:\DevSuiteHome_1\jdk\jre\bin\classic;D:\DevSuiteHome_1\jdk\jre\bin;D:\DevSuiteHome_1\jdk\jre\bin\client;D:\DevSuiteHome_1\jlib;D:\DevSuiteHome_1\bin;D:\DevSuiteHome_1\jre\1.4.2\bin\client;D:\DevSuiteHome_1\jre\1.4.2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\ORANT\BIN;%ORACLE_HOME%\bin;%ORACLE_HOME%\OPatch;%ORACLE_HOME%\sqlj\bin;%JAVA_HOME%\bin;D:\dbhome_2\product\11.2.0\client_1\jdk\bin

 

  1. Make JPublisher and JDK 1.5.0 available for an Oracle Client Operating System Shell

Oracle Client 11g ships with a JDK 1.5.0 already. The JDK being used for JPublisher must match with the version of the OracleJVM the generated classes will be deployed to.

e.g.:
PATH=$ORACLE_HOME\jdk\bin;%PATH %

echo %PATH%
D:\dbhome_2\product\11.2.0\client_1\bin;D:\app\database\product\11.2.0\dbhome_1;D:\app\database\product\11.2.0\dbhome_1\bin;;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;%ORACLE_HOME%\bin;%ORACLE_HOME%\OPatch;%ORACLE_HOME%\sqlj\bin;%JAVA_HOME%\bin;D:\app\database\product\11.2.0\dbhome_1\sqlj\lib;

 

  1. Load the WebService Client into Oracle Database Server

loadjava -u SYS/MiracleWorker7 -r -v -f -s –grant public -genmissing dbwsclientws.jar dbwsclientdb11.jar

Output:

[oracle@sracanov-au2 lib]$ tail -8 loadjava.txt

Classes Loaded: 4061

Resources Loaded: 81

Sources Loaded: 0

Published Interfaces: 0

Classes generated: 63

Classes skipped: 0

Synonyms Created: 0

Errors: 0

[oracle@sracanov-au2 lib]$

 

Note:

The loadjava commands above load the Oracle JAX-RPC client into the target schema. By default this classes will only be available for the target user. Other users require execute privileges and synonyms for this classes, if such users should also be able to have web service callouts.

e.g.:
loadjava -u SYS/MiracleWorker7 -r -v -f -s –grant public -genmissing dbwsclientws.jar dbwsclientdb11.jar

  1. Once the database webservice call out classes have been loaded, I need to run the PL/SQL wrappers that will call these classes. The scripts are found in $ORACLE_HOME\sqlj\lib folder. Since I installed the jar in scott, scott needs to run these scripts:

Load below in sys schema.

  1. sql
  2. sql

Verify.

desc utl_dbws

  1. Here is the PL/SQL code using UTL_DBWS to call an external webservice:

CREATE OR REPLACE FUNCTION celciusToFahrenheit(temperature NUMBER) RETURN VARCHAR2 AS

service_ scott.utl_dbws.SERVICE;

call_ scott.utl_dbws.CALL;

service_qname scott.utl_dbws.QNAME;

port_qname scott.utl_dbws.QNAME;

response sys.XMLTYPE;

request sys.XMLTYPE;

BEGIN

scott.utl_dbws.set_http_proxy(‘myproxy.com:80’);

service_qname := scott.utl_dbws.to_qname(null, ‘CelciusToFahrenheit’);

service_      := scott.utl_dbws.create_service(service_qname);

call_         := scott.utl_dbws.create_call(service_);

scott.utl_dbws.set_target_endpoint_address(call_, ‘http://webservices.daehosting.com/services/TemperatureConversions.wso’);

scott.utl_dbws.set_property( call_, ‘OPERATION_STYLE’, ‘document’);

request       := sys.XMLTYPE(‘<celciustofahrenheit xmlns=”http://webservices.daehosting.com/temperature”><ncelcius>&#8217;||temperature||'</ncelcius></celciustofahrenheit>’);

response      := scott.utl_dbws.invoke(call_, request);

return response.extract(‘//CelciusToFahrenheitResult/child::text()’, ‘xmlns=”http://webservices.daehosting.com/temperature”&#8216;).getstringval();

END;

Now Test:

 

SELECT celciusToFahrenheit(30) from dual;

 

CELCIUSTOFAHRENHEIT(30)

——————————————————————————–

86

 

 

—————————————————————–

Advertisements

Oracle 12c New Features.

The Oracle 12C means different things to different people.It all depends on which areas you are looking at, as there are improvements in many areas. Summarized below is the list of Top 12 Features of Oracle 12C as I see it. I have summarized below, the top 12 which I found interesting.

01. Pluggable Databases Through Database Consolidation:

Oracle is doing every thing to jump into the cloud bandwagon. With 12C, Oracle is trying to address the problem of Multitenancy through this feature. There is a radical change and a major change in the core database architecture through the introduction of Container Databases also called CBD and Pluggable Databases (PDB). The memory and process is owned by the Container Database. The container holds the metadata where the PDBs hold the user data. You can create upto 253 PDBs including the seed PDB.

In a large setup, it is common to see 20 or 30 different instances running in production environment. With these many instances, it is a maintenance nightmare as all these instances have to be separately

•Upgraded
•Patched
•Monitored
•Tuned
•RAC Enabled
•Adjusted
•Backed up and
•Data Guarded.

With Pluggable Databases feature, you just have to do all this for ONE single instance. Without this feature, prior to 12C, you would have to create separate schemas and there is always a thread of security how much ever the isolation we build into it. There are problems with namespace conflicts, there is always going to be one public synonym that you can create. With PDBs you can have a separate HR or Scott schema for each PDB, separate Emp, Dept Tables and separate public synonyms. Additionally, 2 PDBs can talk to each other through the regular DB Link feature. There is no high startup cost of creating a database any more. Instead of one instance per day, the shift is into one instance per many databases. For the developer community, you can be oblivious of all this and still continue to use the PDBs as if it were a traditional database, but for the DBAs the world would look like it has changed a lot.

Another cool feature is, you can allocate a CPU percentage for each PDB.

Another initiative being, it has announced a strategic tieup with salesforce.com during the first week of July 2013.

 

02. Redaction Policy:

This is one of the top features in Oracle 12C. Data Redaction in simple terms means, masking of data. You can setup a Data Redaction policy, for example SSN field in a Employee table can be masked. This is called redaction. From Sql Develop you can do this by going to the table: Employee->Right click on Security Policy->click on New->click on Redaction Policy->Enter SSN.
When you do a select * from employee, it will show that the SSN is masked.
The new data masking will use a package called DBMS_REDACT. It is the extension to the FGAC and VPD present in earlier versions.
By doing this, whoever needs to view the data will be able to see it where as the other users will not be able to view it.

 

03. Top N Query and Fetch and offset Replacement to Rownum:

With the release of Oracle Database 12c, Oracle has introduced this new SQL syntax to simplify fetching the first few rows. The new sql syntax “Fetch First X Rows only” can be used.

 

04. Adaptive Query Optimization and Online Stats Gathering:

With this feature, it helps the optimizer to make runtime adjustments to execution plan which leads to better stats. For statements like CTAS (Create Table As Select) and IAS (Insert As Select), the stats is gathered online so that it is available immediately.

 

05. Restore a Table easily through RMAN:

Earlier if you had to restore a particular table, you had to do all sorts of things like restoring a tablespace and or do Export and Import. The new restore command in RMAN simplifies this task.

 

06. Size Limit on Varchar2, NVarchar2, Raw Data Types increased:

The previous limit on these data types was 4K. In 12C, it has been increased to 32,767 bytes. Upto 4K, the data is stored inline. I am sure everyone will be happy with this small and cute enhancement.

 

07. Inline PL/SQL Functions and Procedures:

The in line feature is extended in Oracle 12C. In addition to Views, we can now have PL/SQL Procedures and Functions as in line constructs. The query can be written as if it is calling a real stored procedure, but however the functions do not actually exist in the database. You will not be able to find them in ALL_OBJECTS. I think this will be a very good feature for the developers to explore as there is no code that needs to be compiled.

 

08. Generated as Identity/Sequence Replacement:

You can now create a col with ‘generated as identity’ clause. Thats it. Doing this is equivalent to creating a separate sequence and doing a sequence.nextval for each row. This is another handy and a neat feature which will help developer community. This is also called No Sequence Auto Increment Primary Key.

 

09. Multiple Indexes on a Single Column:

Prior to 12C, a column cant be in more than one index. In 12C, you can include a column in B-tree index as well as a Bit Map index. But, please note that only one index is usable at a given time.

 

10. Online Migration of Table Partition or Sub Partition:

You can very easily migrate a partition or sub partition from one tablespace to another. Similar to how the online migration was achieved for a non-partitioned table in prior releases, a table partition or sub partition can be moved to another tablespace online or offline. When an ONLINE clause is specified, all DML operations can be performed without any interruption on the partition|sub-partition which is involved in the procedure. In contrast, no DML operations are allowed if the partition|sub-partition is moved offline.

 

11. Temporary UNDO:

Prior to 12C, undo records generated by TEMP Tablespace is stored in the undo tablespace. With Temp undo feature in 12C, temp undo records can be stored in temporary table instead of UNDO TS. The benefit is – reduced undo tablespace and reduced redo log space used.

SQL> ALTER SYSTEM SET PGA_AGGREGATE_LIMIT=2G;
SQL> ALTER SYSTEM SET PGA_AGGREGATE_LIMIT=0; –disables the hard limit

 

12. In Database Archiving:

This feature enables archiving rows within a table by marking them as inactive. These inactive rows are in the database and can be optimized using compression but are not visible to the application. These records are skipped during FTS (Full Table Scan).

Tablespace Encryption in Oracle

Oracle 11g Database Release 1

The Transparent Data Encryption (TDE) feature was introduced in Oracle 10g Database Release 2 to simplify the encryption of data within datafiles, preventing access to it from the operating system. Tablespace encryption extends this technology, allowing encryption of the entire contents of a tablespace, rather than having to configure encryption on a column-by-column basis.

  • Wallet Creation
  • Tablespace Creation
  • Test Encryption

Wallet Creation

The environment setup for tablespace encryption is the same as that for transparent data encryption. Before attempting to create an encrypted tablespace, a wallet must be created to hold the encryption key. The search order for finding the wallet is as follows:

  1. If present, the location specified by the ENCRYPTION_WALLET_LOCATION parameter in the sqlnet.ora file.
  2. If present, the location specified by the WALLET_LOCATION parameter in the sqlnet.ora file.
  3. The default location for the wallet ($ORACLE_BASE/admin/$ORACLE_SID/wallet).

Although encrypted tablespaces can share the default database wallet, Oracle recommend you use a separate wallet for transparent data encryption functionality by specifying theENCRYPTION_WALLET_LOCATION parameter in the sqlnet.ora file. To accomplish this we add the following entry into the sqlnet.ora file on the server and make sure the specified directory has been created.

ENCRYPTION_WALLET_LOCATION=

(SOURCE=(METHOD=FILE)(METHOD_DATA=

(DIRECTORY=/u01/app/oracle/admin/DB11G/encryption_wallet/)))

This parameter can also be used to identify a Hardware Security Model (HSM) as the location for the wallet.

The following command creates and opens the wallet.

CONN sys/password@db11g AS SYSDBA

ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY “myPassword”;

Wallets must be reopened after an instance restart and can be closed to prevent access to encrypted data.

ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY “myPassword”;

ALTER SYSTEM SET ENCRYPTION WALLET CLOSE;

Tablespace Creation

Encrypted tablespaces are created by specifying the ENCRYPTION clause with an optional USING clause to specify the encryption algorithm. If the USING clause is omitted, the encryption algorithm defaults to ‘AES128’. In addition, the default storage clause of ENCRYPT must be specified. Tablespace encryption does not allow the NO SALT option that is available in TDE. The following statement creates an encrypted tablespace by explicitly naming the ‘AES256’ encryption algorithm in the USING clause.

CREATE TABLESPACE encrypted_ts

DATAFILE ‘/u01/app/oracle/oradata/DB11G/encrypted_ts01.dbf’ SIZE 128K

AUTOEXTEND ON NEXT 64K

ENCRYPTION USING ‘AES256’

DEFAULT STORAGE(ENCRYPT);

ALTER USER test QUOTA UNLIMITED ON encrypted_ts;

The ENCRYPTED column of the DBA_TABLESPACES and USER_TABLESPACES views indicates if the tablespace is encrypted or not.

SELECT tablespace_name, encrypted FROM dba_tablespaces;

TABLESPACE_NAME                ENC

—————————— —

SYSTEM                         NO

SYSAUX                         NO

UNDOTBS1                       NO

TEMP                           NO

USERS                          NO

ENCRYPTED_TS                   YES

6 rows selected.

SQL>

Regular tablespaces cannot be converted to encrypted tablespaces. Instead, data must be transferred manually using export/import, “ALTER TABLE … MOVE …” or “CREATE TABLE … AS SELECT * FROM …”.

Test Encryption

With the tablespace in place, we can create some objects to test the encryption. The following code creates a table and index in the encrypted tablespace and inserts a single row into the table.

CONN test/test@db11g

CREATE TABLE ets_test (

id    NUMBER(10),

data  VARCHAR2(50)

)

TABLESPACE encrypted_ts;

CREATE INDEX ets_test_idx ON ets_test(data) TABLESPACE encrypted_ts;

INSERT INTO ets_test (id, data) VALUES (1, ‘This is a secret!’);

COMMIT;

Flush the buffer cache to make sure the data is written to the datafile.

CONN sys/password@db11g AS SYSDBA

ALTER SYSTEM FLUSH BUFFER_CACHE;

When the file is opened using a HEX editor (like UltraEdit) only non-printable characters are present. The ‘This is a secret!’ string is not visible in the table or index data within the encrypted tablespace.

When you are finished testing the encrypted tablespace, be sure to clean up the tablespace and associated datafile.

DROP TABLESPACE encrypted_ts INCLUDING CONTENTS AND DATAFILES;

Data Encryption in Oracle

Transparent Data Encryption (TDE) in Oracle 10g database

Oracle has many security features available within the database, but until now there has been no “out-of-the-box” method for protecting the data at the operating system level. The Transparent Data Encryption (TDE) feature introduced in Oracle 10g Database Release 2 allows sensitive data to be encrypted within the datafiles to prevent access to it from the operating system. This article presents some basic examples of its use.

  • Setup
  • Normal Column
  • Encrypted Column
  • Performance
  • External Tables
  • Views

Setup

In order to show the encryption working we need to open a datafile in a HEX editor. Rather than trying to open a huge datafile, it makes sense to create a small file for this test.

CONN sys/password AS SYSDBA

CREATE TABLESPACE tde_test

DATAFILE ‘/u01/oradata/DB10G/tde_test.dbf’ SIZE 128K

AUTOEXTEND ON NEXT 64K;

Next, create a user with with a quota on the new tablespace.

CREATE USER test IDENTIFIED BY test DEFAULT TABLESPACE tde_test;

ALTER USER test QUOTA UNLIMITED ON tde_test;

GRANT CONNECT TO test;

GRANT CREATE TABLE TO test;

Normal Column

First we will prove that the data from a normal column can be seen from the OS. To do this create a test table and insert some data.

CONN test/test

CREATE TABLE tde_test (

id    NUMBER(10),

data  VARCHAR2(50)

)

TABLESPACE tde_test;

INSERT INTO tde_test (id, data) VALUES (1, ‘This is a secret!’);

COMMIT;

Then flush the buffer cache to make sure the data is written to the datafile.

CONN sys/password AS SYSDBA

ALTER SYSTEM FLUSH BUFFER_CACHE;

Open the datafile using a HEX editor (like UltraEdit) and the sentence “This is a secret!” is clearly visible amongst all the non-printable characters.

Encrypted Column

Before attempting to create a table with encrypted columns, a wallet must be created to hold the encryption key. The search order for finding the wallet is as follows:

  1. If present, the location specified by the ENCRYPTION_WALLET_LOCATION parameter in the sqlnet.ora file.
  2. If present, the location specified by the WALLET_LOCATION parameter in the sqlnet.ora file.
  3. The default location for the wallet ($ORACLE_BASE/admin/$ORACLE_SID/wallet).

Although encrypted tablespaces can share the default database wallet, Oracle recommend you use a separate wallet for transparent data encryption functionality by specifying theENCRYPTION_WALLET_LOCATION parameter in the sqlnet.ora file. To accomplish this we add the following entry into the sqlnet.ora file on the server and make sure the specified directory has been created.

ENCRYPTION_WALLET_LOCATION=

(SOURCE=(METHOD=FILE)(METHOD_DATA=

(DIRECTORY=/u01/app/oracle/admin/DB10G/encryption_wallet/)))

The following command creates and opens the wallet.

CONN sys/password AS SYSDBA

— 10g version

ALTER SYSTEM SET ENCRYPTION KEY AUTHENTICATED BY “myPassword”;

— 11g version

ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY “myPassword”;

Wallets must be reopened after an instance restart and can be closed to prevent access to encrypted columns.

— 10g version

ALTER SYSTEM SET ENCRYPTION WALLET OPEN AUTHENTICATED BY “myPassword”;

— 11g version

ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY “myPassword”;

ALTER SYSTEM SET ENCRYPTION WALLET CLOSE;

Create a test table with an encrypted column and insert some data. Using the ENCRYPT clause on its own is the same as using the ENCRYPT USING ‘AES192’ clause, as AES192 is the default encryption method.

CONN test/test

DROP TABLE tde_test;

PURGE RECYCLEBIN;

CREATE TABLE tde_test (

id    NUMBER(10),

data  VARCHAR2(50) ENCRYPT

)

TABLESPACE tde_test;

INSERT INTO tde_test (id, data) VALUES (1, ‘This is a secret!’);

COMMIT;

Flush the buffer cache to make sure the data is written to the datafile.

CONN sys/password AS SYSDBA

ALTER SYSTEM FLUSH BUFFER_CACHE;

When the file is opened using a HEX editor only non-printable characters are present. The test sentence cannot be seen anywhere, but the data is still clearly visible from a database connection.

SELECT * FROM tde_test;

ID DATA

———- ————————————————–

1 This is a secret!

1 row selected.

Performance

There is a performance overhead associated with the encryption/decryption process. The following tables are used in a performance comparison.

CONN test/test

CREATE TABLE tde_test_1 (

id    NUMBER(10),

data  VARCHAR2(50)

)

TABLESPACE tde_test;

CREATE TABLE tde_test_2 (

id    NUMBER(10),

data  VARCHAR2(50) ENCRYPT

)

TABLESPACE tde_test;

The following script uses these tables to compare the speed of regular and encrypted inserts and regular and decrypted queries. Each test repeats 1000 times, with the timings reported in 100ths of a second.

SET SERVEROUTPUT ON SIZE UNLIMITED

DECLARE

l_loops  NUMBER := 1000;

l_data   VARCHAR2(50);

l_start  NUMBER;

BEGIN

EXECUTE IMMEDIATE ‘TRUNCATE TABLE tde_test_1’;

EXECUTE IMMEDIATE ‘TRUNCATE TABLE tde_test_2’;

l_start := DBMS_UTILITY.get_time;

FOR i IN 1 .. l_loops LOOP

INSERT INTO tde_test_1 (id, data)

VALUES (i, ‘Data for ‘ || i);

END LOOP;

DBMS_OUTPUT.put_line(‘Normal Insert   : ‘ || (DBMS_UTILITY.get_time – l_start));

l_start := DBMS_UTILITY.get_time;

FOR i IN 1 .. l_loops LOOP

INSERT INTO tde_test_2 (id, data)

VALUES (i, ‘Data for ‘ || i);

END LOOP;

DBMS_OUTPUT.put_line(‘Encrypted Insert: ‘ || (DBMS_UTILITY.get_time – l_start));

l_start := DBMS_UTILITY.get_time;

FOR i IN 1 .. l_loops LOOP

SELECT data

INTO   l_data

FROM   tde_test_1

WHERE  id = i;

END LOOP;

DBMS_OUTPUT.put_line(‘Normal Query    : ‘ || (DBMS_UTILITY.get_time – l_start));

l_start := DBMS_UTILITY.get_time;

FOR i IN 1 .. l_loops LOOP

SELECT data

INTO   l_data

FROM   tde_test_2

WHERE  id = i;

END LOOP;

DBMS_OUTPUT.put_line(‘Decrypted Query : ‘ || (DBMS_UTILITY.get_time – l_start));

END;

/

Normal Insert   : 31

Encrypted Insert: 45

Normal Query    : 42

Decrypted Query : 58

PL/SQL procedure successfully completed.

SQL>

The results clearly demonstrate that encrypted inserts and decrypted queries are slower than their normal counterparts.

External Tables

External tables can be encrypted in a similar way to regular tables. First, we make sure the default data pump directory is available to the test user.

CONN sys/password AS SYSDBA

GRANT READ, WRITE ON DIRECTORY data_pump_dir TO test;

Next, we create the external table as a copy of an existing table, using the ENCRYPT clause.

CONN test/test

CREATE TABLE tde_test_1_ext (

id,

data ENCRYPT IDENTIFIED BY “myPassword”

)

ORGANIZATION EXTERNAL

(

TYPE ORACLE_DATAPUMP

DEFAULT DIRECTORY data_pump_dir

location (‘tde_test_1_ext.dmp’)

)

AS

SELECT id,

data

FROM   tde_test_1;

Views

The %_ENCRYPTED_COLUMNS views are used to display information about encrypted columns.

SET LINESIZE 100

COLUMN owner FORMAT A15

COLUMN tble_name FORMAT A15

COLUMN column_name FORMAT A15

SELECT * FROM dba_encrypted_columns;

OWNER           TABLE_NAME                     COLUMN_NAME     ENCRYPTION_ALG                SAL

————— —————————— ————— —————————– —

TEST            TDE_TEST_2                     DATA            AES 192 bits key              YES

TEST            TDE_TEST_1_EXT                 DATA            AES 192 bits key              YES

2 rows selected.

Oracle new features & enhancements Release wise

Oracle new features & enhancements

New Features of Oracle10g release 2:

  • Web server load balancing – The web cache component includes Apache extension to load-balance transactions to the least-highly-loaded Oracle HTTP server (OHS).
  • RAC instance load balancing – Staring in Oracle 10g release 2, Oracle JDBC and ODP.NET provide connection pool load balancing facilities through integration with the new “load balancing advisory” tool.  This replaces the more-cumbersome listener-based load balancing technique.
  • Automated Storage Load balancing – Oracle’s Automatic Storage Management (SAM) now enables a single storage pool to be shared by multiple databases for optimal load balancing.  Shared disk storage resources can alternatively be assigned to individual databases and easily moved from one database to another as processing requirements change.
  • Data Guard Load Balancing – Oracle Dataguard allows for load balancing between standby databases.
  • Listener Load Balancing – If advanced features such as load balancing and automatic failover are desired, there are optional sections of the listener.ora file that must be present.  Automatic Storage Management (ASM) includes multiple disk operations and a non-ASM database migration utility
  • Enhancements to data provisioning and Oracle Streams designed to make it easier to archive, move, and copy large data sets
  • New Fast-Start Failover for automatic fail over to standby databases
  • Integrated data encryption and key management in the database
  • Automated statistics collection directly from memory designed to eliminate the need to execute SQL queries
  • New administrative reports include automatic database workload repository comparison
  • Extended use of Standard Chunk sizes – In 10gR2, the server has been enhanced to further leverage standard chunk allocation sizes. This additional improvement reduces the number of problems arising from memory fragmentation.
  • Mutexes – To improve cursor execution and also hard parsing, a new memory serialization mechanism has been created in 10gR2. For certain shared-cursor related operations, mutexes are used as a replacement for library cache latches and librarycache pins. Using mutexes is faster, uses less CPU and also allows significantly improved concurrency over the existing latch mechanism. The use of mutexes for cursor pins can be enabled by setting the init.ora parameter _use_kks_mutex to TRUE.
  • V$SGASTAT – V$SGASTAT has been enhanced to display a finer granularity of memory to component allocation within the shared pool. This allows faster diagnosis of memory usage (in prior releases many smaller allocations were grouped under the ‘miscellaneous’ heading).
  • V$SQLSTAT – A new view, V$SQLSTAT has been introduced which contains SQL related statistics (such as CPU time, elapsed time, sharable memory). This view is very cheap to query even on high-concurrency systems, as it does not require librarycache latch use. It contains the most frequently used SQL statistics in the V$SQL family of views.
  • V$OPEN_CURSOR – This implementation of this view has also been enhanced to be latchless, making it inexpensive to query.
  • V$SQLAREA – The V$SQLAREA view has been improved in 10gR2; the view optimizes the aggregation of the SQL statements while generating the view data.

New Features in Oracle10g release 10.1.0

  • Oracle10g Grid – RAC enhanced for Oracle10g dynamic scalability with server blades
  • Completely reworked 10g Enterprise Manager (OEM)
  • AWR and ASH tables incorporated into OEM Performance Pack and Diagnostic Pack options
  • Automated Session History (ASH) materializes the Oracle Wait Interface over time
  • Data Pump replaces imp utility with impdp
  • Automatic Database Diagnostic Monitor (ADDM)
  • Automatic Storage Management (ASM) introduced Stripe And Mirror Everywhere (SAME) standard
  • Automatic Workload Repository (AWR) replaces STATSPACK
  • SQLTuning Advisor
  • SQLAccess Advisor
  • Rolling database upgrades (using Oracle10g RAC)
  • dbms_scheduler package replaces dbms_job for scheduling
  • OEM Partition Manager introduced

Miscellaneous Oracle10g enhancements:

  • Set Database Default Tablespace syntax
  • Rename Tablespace command
  • Introduced RECYCLEBIN command for storing objects before they are dropped. Required new PURGE command for maintenance.
  • sqlplus / as sysdba accessibility without quote marks
  • SYSAUX tablespace
  • Multiple Temporary Tablespaces supported to reduce stress on sorting in TEMP
  • RMAN introduces compression for backups
  • New drop database syntax
  • New alter database begin backup syntax
  • Oracle10g Data Guard Broker introduced
  • Oracle10g RAC supports secure Redo Log transport
  • Flashback enhancements for flashback database and flashback table syntax
  • SQL Apply feature
  • VPD (FGAC, RLS) supports both row-level and column-level VPD
  • Cross Platform Transportable Tablespaces
  • External Table unload utility
  • SQL Regular Expression Support with the evaluate syntax
  • New ROW TIMESTAMP column
  • Improvement to SSL handshake speed
  • Automatic Database Tuning of Checkpoints, Undo Segments and shared memory
  • Automated invoking of dbms_stats for CBO statistics collection
  • RAC introduces Integrated Cluster ware
  • Oracle Application Builder supports HTML DB
  • Browser Based Data Workshop and SQL Workshop
  • PL/SQL Compiler enhanced for compile-time Warnings in utl_mail and utl_compress
  • VPD (FGAC, RLS) supports both row-level and column-level VPD
  • External Table unload utility
  • SQL Regular Expression Support with the evaluate syntax
  • New ROW TIMESTAMP column

Feature Enhancements in Oracle9i 9.2:

  • Oracle Streams
  • RAC Cluster Guard II introduced
  • XML DB enhanced for XML repository
  • Oracle JVM made compliant with JDK 1.3
  • SQL Apply added to Oracle DataGuard
  • Locally Managed tablespaces (LMT) for the SYSTEM tablespaces
  • Default Install Account locking
  • VPD adds support for table and column synonyms

Major new utilities in Oracle9i – (9.0.1):

  • Oracle Data Guard introduced
  • Oracle9i Real Application Clusters introduced
  • Oracle9i Flashback Utility (dbms_flashback)
  • Online table reorganization with dbms_redefinition
  • Database Configuration Assistant (DBCA) – OEM Wizard
  • Multiple blocksize support
  • New blocksize parameter for create tablespace syntax
  • Easy extraction of DDL with dbms_metadata package
  • System-level triggers – startup trigger DDL trigger
  • Oracle Internet File System (IFS) becomes functional
  • Oracle upsert statement introduced
  • SQL case statement replaces decode syntax
  • Oracle external tables

Feature Enhancements on Oracle9i 9.0.1:

  • New v$sql_plan allows execution plan analysis
  • New set autotrace traceonly explain syntax for SQL*Plus replace explain plan syntax
  • System-managed rollback segments
  • Updateable Scrollable Cursors
  • analyze command and dbms_utility.analyze_schema replaced by dbms_stats package
  • connect as sysdba replaces as sysdba syntax in SQL*Plus
  • Crummy svrmgrl utility disappears
  • List Partitioning the multi-level list-hash partitioning
  • RMAN allows re-startable backups
  • RMAN supports block-level recovery
  • Oracle ultra-search

Oracle Enhancements 8i (8.1.7)

  • Oracle HTTP server gets Apache extensions
  • Oracle Integration Server (OIS) introduced
  • PL/SQL Gateway introduced for deploying PL/SQL based solutions on the Web
  • Oracle JVM Accelerator
  • Java Server Pages (JSP) engine
  • New memstat utility for analyzing Java Memory footprints
  • OEM auto-discover for new services
  • New UNDO tablespace
  • Oracle Character Set Migration utility

New features in Oracle 8i (8.1.6)

  • PL/SQL Server Pages (PSP’s)
  • Oracle DBA Studio Introduced
  • New SQL analytic Functions (rank, moving average)
  • Alter table xxx storage (freelists) command supported
  • Java XML parser
  • PL/SQL dbms_crypto_toolkit encryption package

New Features in Oracle8i 8.1.5:

  • Oracle Log Miner
  • Oracle iFS
  • JAVA stored procedures introduced (Oracle Java VM)
  • Virtual private database (VPD, FGAC) using dbms_rls package
  • Locally managed tablespace (LMT) reduces dictionary contention

New Feature Enhancements in Oracle8i 8.1.5:

  • Functional based indexes (FBI)
  • ESTAT/BSTAT is made obsolete by STATSPACK
  • MTTR Fast Start recovery – Checkpoint rate auto-adjusted to match roll forward criteria
  • Online index rebuilding
  • Support for alter table xxx drop column syntax
  • Oracle Parallel Server (OPS) adds Cache Fusion
  • Advanced Queuing improved
  • New execute immediate syntax
  • New dbms_debug package
  • Oracle users and roles can be accessed across dblinks for multiple databases
  • Resource Management introduces priorities and resource classes
  • Partitioned tables enhanced for Hash and Composite partitioning
  • SQL*Loader introduces a direct load API
  • dbms_stats enhanced to allow saving and migration of CBO statistics
    analyze table in parallel
  • Net8 support for SSL, HTTP, HOP protocols

Major Enhancements in Oracle8 – Release 8.0

  • Nested tables
  • OID addressing
  • Pointers allowed in table columns
  • VARRAY support within tables (non first normal form tables)
  • New create type syntax
  • Table Partitioning and Index partitioning enhancements
  • Oracle Universal Server introduced
  • Oracle Data Cartridges introduced for Oracle Spatial
  • Oracle ConText cartridge introduced
  • RMAN introduced to replace Enterprise Backup Utility (EBU)
  • RMAN has incremental backups and parallel syntax support
  • Oracle security server introduced (precursor to Oracle SSO)
  • Oracle WebServer enhanced

Other Oracle8 8.0 enhancements:

  • OPS introduces $gv views
  • OPS allows transparent failover to a new node
  • OPS has Oracle-created Integrated Distributed Lock Manager (IDLM)
  • Ability to call external procedures
  • exp enhanced to export specific table partitions
  • online/offline, backup/recover individual partitions
  • reverse key index supported
  • updatable views
  • syntax to merge and balance partitions
  • Advanced Queuing allows message handling
  • parallel syntax supported for insert, update and delete DML
  • MTS connection pooling
  • Improved “STAR” query joins in CBO
  • Tablespace point in time recovery (TSPITR)
  • Oracle password expiration feature
  • Database links are privileged (no embedded passwords)
  • Oracle Replication manager introduced into OEM
  • Deferred Oracle constraints aids data loading
  • SQL*Net v 2 is renamed to Net8

Major enhancements in Oracle 7.3:

  • Bitmap Indexes
  • Partitioned Views
  • Oracle Standby Database packages
  • Full table scans support prefetch (asynchronous read ahead)
  • alter index xx rebuild syntax
  • Oracle db_verify package for corruption detection
  • Oracle block editor (BBED) created
  • Oracle Spatial
  • Oracle ConText
  • Oracle Trace

Other New Features in Oracle 7.3:

  • Updatable Join Views
  • SQL*DBA obseleted
  • Alter tablespace coalesce syntax
  • temporary parameter added to create tablespace syntax for TEMP tablespace
  • extents unlimited syntax added to table syntax
  • CBO introduced histograms for skewed columns and n-way joins
  • CBO introduces hash joins and hash_area_size parameter
  • CBO supports antijoins for NOT subqueries
  • New dba_histograms view
  • New utl_file package allows interface to flat files

New features in Oracle 7.2

  • Manual Shrink Rollback Segment syntax
  • Resizing of datafiles introduced with resize syntax
  • New dbms_job package
  • Autoextend option added for data files

 

Materialized View

MATERIALIZED VIEW:

A materialized view is a database object that contains the results of a query. They are local copies of data located remotely, or are used to create summary tables based on aggregations of a table’s data. Materialized views, which store data based on remote tables are also, know as snapshots.

A materialized view is a database object that contains the results of a query. The FROM clause of the query can name tables, views, and other materialized views. Collectively these objects are called master tables (a replication term) or detail tables (a data warehousing term). This reference uses “master tables” for consistency. The databases containing the master tables are called the master databases.

A materialized view can query tables, views, and other materialized views. Collectively these are called master tables (a replication term) or detail tables (a data warehouse term).

For replication purposes, materialized views allow you to maintain copies of remote data on your local node. These copies are read-only. If you want to update the local copies, you have to use the Advanced Replication feature. You can select data from a materialized view as you would from a table or view.

For replication purposes, materialized views allow you to maintain copies of remote data on your local node. The copies can be updatable with the Advanced Replication feature and are read-only without this feature. You can select data from a materialized view as you would from a table or view. In replication environments, the materialized views commonly created are primary key, rowid, object, and subquery materialized views.

For data warehousing purposes, the materialized views commonly created are aggregate views, single-table aggregate views, and join views.

For data warehousing purposes, the materialized views commonly created are materialized aggregate views, single-table materialized aggregate views, and materialized join views. All three types of materialized views can be used by query rewrite, an optimization technique that transforms a user request written in terms of master tables into a semantically equivalent request that includes one or more materialized views.

Prerequisites:

The privileges required to create a materialized view should be granted directly rather than through a role.

To create a materialized view in your own schema:

  • You must have been granted the CREATE MATERIALIZED VIEW system privilege and either the CREATE TABLE or CREATE ANY TABLE system privilege.
  • You must also have access to any master tables of the materialized view that you do not own, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.

To create a materialized view in another user’s schema:

  • You must have the CREATE ANY MATERIALIZED VIEW system privilege.
  • The owner of the materialized view must have the CREATE TABLE system privilege. The owner must also have access to any master tables of the materialized view that the schema owner does not own (for example, if the master tables are on a remote database) and to any materialized view logs defined on those master tables, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.

To create a refresh-on-commit materialized view (ON COMMIT REFRESH clause), in addition to the preceding privileges, you must have the ON COMMIT REFRESH object privilege on any master tables that you do not own or you must have the ON COMMIT REFRESH system privilege.

To create the materialized view with query rewrite enabled, in addition to the preceding privileges:

  • If the schema owner does not own the master tables, then the schema owner must have the GLOBAL QUERY REWRITE privilege or the QUERY REWRITE object privilege on each table outside the schema.
  • If you are defining the materialized view on a prebuilt container (ON PREBUILT TABLE clause), then you must have the SELECT privilege WITH GRANT OPTION on the container table.

The user whose schema contains the materialized view must have sufficient quota in the target tablespace to store the master table and index of the materialized view or must have the UNLIMITED TABLESPACE system privilege.

When you create a materialized view, Oracle Database creates one internal table and at least one index, and may create one view, all in the schema of the materialized view. Oracle Database uses these objects to maintain the materialized view data. You must have the privileges necessary to create these objects.

In this article, we shall see how to create a Materialized View and discuss Refresh Option of the view.

In replication environments, the materialized views commonly created are primary key, rowid, and subquery materialized views.

Primary Key Materialized Views

The following statement creates the primary-key materialized view on the table emp located on a remote database.

SQL>    CREATE MATERIALIZED VIEW mv_emp_pk
        REFRESH FAST START WITH SYSDATE 
        NEXT  SYSDATE + 1/48
        WITH PRIMARY KEY 
        AS SELECT * FROM emp@remote_db;

Materialized view created.

Note: When you create a materialized view using the FAST option you will need to create a view log on the master tables(s) as shown below:

SQL> CREATE MATERIALIZED VIEW LOG ON emp;
Materialized view log created.

Rowid Materialized Views

The following statement creates the rowid materialized view on table emp located on a remote database:

 

SQL>    CREATE MATERIALIZED VIEW mv_emp_rowid 
        REFRESH WITH ROWID 
        AS SELECT * FROM emp@remote_db; 

Materialized view log created.

Subquery Materialized Views

The following statement creates a subquery materialized view based on the emp and dept tables located on the remote database:

SQL> CREATE MATERIALIZED VIEW  mv_empdept
AS SELECT * FROM emp@remote_db e
WHERE EXISTS
     (SELECT * FROM dept@remote_db d
     WHERE e.dept_no = d.dept_no)

REFRESH CLAUSE

[refresh [fast|complete|force]
            [on demand | commit]
            [start with date] [next date]
            [with {primary key|rowid}]]

The refresh option specifies:

  1. The refresh method used by Oracle to refresh data in materialized view
  2. Whether the view is primary key based or row-id based
  3. The time and interval at which the view is to be refreshed

Refresh Method – FAST Clause

The FAST refreshes use the materialized view logs (as seen above) to send the rows that have changed from master tables to the materialized view.

You should create a materialized view log for the master tables if you specify the REFRESH FAST clause.

SQL> CREATE MATERIALIZED VIEW LOG ON emp;

Materialized view log created.

Materialized views are not eligible for fast refresh if the defined subquery contains an analytic function.

Refresh Method – COMPLETE Clause

The complete refresh re-creates the entire materialized view. If you request a complete refresh, Oracle performs a complete refresh even if a fast refresh is possible.

Refresh Method –FORCE Clause

When you specify a FORCE clause, Oracle will perform a fast refresh if one is possible or a complete refresh otherwise. If you do not specify a refresh method (FAST, COMPLETE, or FORCE), FORCE is the default.

PRIMARY KEY and ROWID Clause

WITH PRIMARY KEY is used to create a primary key materialized view i.e. the materialized view is based on the primary key of the master table instead of ROWID (for ROWID clause). PRIMARY KEY is the default option. To use the PRIMARY KEY clause you should have defined PRIMARY KEY on the master table or else you should use ROWID based materialized views.

Primary key materialized views allow materialized view master tables to be reorganized without affecting the eligibility of the materialized view for fast refresh.

Rowid materialized views should have a single master table and cannot contain any of the following:

  • Distinct or aggregate functions
  • GROUP BY Subqueries , Joins & Set operations

Timing the refresh

The START WITH clause tells the database when to perform the first replication from the master table to the local base table. It should evaluate to a future point in time. The NEXT clause specifies the interval between refreshes

SQL>     CREATE MATERIALIZED VIEW mv_emp_pk
            REFRESH FAST 
            START WITH SYSDATE 
            NEXT  SYSDATE + 2
            WITH PRIMARY KEY 
            AS SELECT * FROM emp@remote_db;

Materialized view created.

In the above example, the first copy of the materialized view is made at SYSDATE and the interval at which the refresh has to be performed is every two days.

Summary

Materialized Views thus offer us flexibility of basing a view on Primary key or ROWID, specifying refresh methods and specifying time of automatic refreshes.


 

Differences between Oracle 9i and 10g

Differences between Oracle 9i and 10g

Each release of Oracle has many differences, and Oracle 10g is a major re-write of the Oracle kernel from Oracle 9i.  I keep a list of the differences and make sure to see these important differences when migrating from 9i to Oracle 10g.  While there are several hundred new features and other differences between 9i and 10g, here are the major differences between Oracle9i and Oracle10g:

  • Major changes to SQL optimizer internals
  • Oracle Grid computing
  • AWR and ASH tables incorporated into Oracle Performance Pack and Diagnostic Pack options
  • Automated Session History (ASH) materializes the Oracle Wait Interface over time
  • Data Pump replaces imp utility with impdp
  • Automatic Database Diagnostic Monitor (ADDM)
  • SQLTuning Advisor
  • SQLAccess Advisor
  • Rolling database upgrades (using Oracle10g RAC)
  • dbms_scheduler package replaces dbms_job for scheduling

Other notes on differences between 9i and 10g:

New Features of Oracle10g release 2:

  • Web server load balancing – The web cache component includes Apache extension to load-balance transactions to the least-highly-loaded Oracle HTTP server (OHS).
  • RAC instance load balancing – Staring in Oracle 10g release 2, Oracle JDBC and ODP.NET provide connection pool load balancing facilities through integration with the new “load balancing advisory” tool.  This replaces the more-cumbersome listener-based load balancing technique.
  • Automated Storage Load balancing – Oracle’s Automatic Storage Management (SAM) now enables a single storage pool to be shared by multiple databases for optimal load balancing.  Shared disk storage resources can alternatively be assigned to individual databases and easily moved from one database to another as processing requirements change.
  • Data Guard Load Balancing – Oracle Dataguard allows for load balancing between standby databases.
  • Listener Load Balancing – If advanced features such as load balancing and automatic failover are desired, there are optional sections of the listener.ora file that must be present.  Automatic Storage Management (ASM) includes multiple disk operations and a non-ASM database migration utility
  • Enhancements to data provisioning and Oracle Streams designed to make it easier to archive, move, and copy large data sets
  • New Fast-Start Failover for automatic fail over to standby databases
  • Integrated data encryption and key management in the database
  • Automated statistics collection directly from memory designed to eliminate the need to execute SQL queries
  • New administrative reports include automatic database workload repository comparison
  • Extended use of Standard Chunk sizes – In 10gR2, the server has been enhanced to further leverage standard chunk allocation sizes. This additional improvement reduces the number of problems arising from memory fragmentation.
  • Mutexes – To improve cursor execution and also hard parsing, a new memory serialization mechanism has been created in 10gR2. For certain shared-cursor related operations, mutexes are used as a replacement for library cache latches and librarycache pins. Using mutexes is faster, uses less CPU and also allows significantly improved concurrency over the existing latch mechanism. The use of mutexes for cursor pins can be enabled by setting the init.ora parameter _use_kks_mutex to TRUE.
  • V$SGASTAT – V$SGASTAT has been enhanced to display a finer granularity of memory to component allocation within the shared pool. This allows faster diagnosis of memory usage (in prior releases many smaller allocations were grouped under the ‘miscellaneous’ heading).
  • V$SQLSTAT – A new view, V$SQLSTAT has been introduced which contains SQL related statistics (such as CPU time, elapsed time, sharable memory). This view is very cheap to query even on high-concurrency systems, as it does not require librarycache latch use. It contains the most frequently used SQL statistics in the V$SQL family of views.
  • V$OPEN_CURSOR – This implementation of this view has also been enhanced to be latchless, making it inexpensive to query.
  • V$SQLAREA – The V$SQLAREA view has been improved in 10gR2; the view optimizes the aggregation of the SQL statements while generating the view data.

New Features in Oracle10g release 10.1.0

  • Oracle10g Grid – RAC enhanced for Oracle10g dynamic scalability with server blades
  • Completely reworked 10g Enterprise Manager (OEM)
  • AWR and ASH tables incorporated into OEM Performance Pack and Diagnostic Pack options
  • Automated Session History (ASH) materializes the Oracle Wait Interface over time
  • Data Pump replaces imp utility with impdp
  • Automatic Database Diagnostic Monitor (ADDM)
  • Automatic Storage Management (ASM) introduced Stripe And Mirror Everywhere (SAME) standard
  • Automatic Workload Repository (AWR) replaces STATSPACK
  • SQLTuning Advisor
  • SQLAccess Advisor
  • Rolling database upgrades (using Oracle10g RAC)
  • dbms_scheduler package replaces dbms_job for scheduling
  • OEM Partition Manager introduced

Miscellaneous Oracle10g enhancements:

  • Set Database Default Tablespace syntax
  • Rename Tablespace command
  • Introduced RECYCLEBIN command for storing objects before they are dropped. Required new PURGE command for maintenance.
  • sqlplus / as sysdba accessibility without quote marks
  • SYSAUX tablespace
  • Multiple Temporary Tablespaces supported to reduce stress on sorting in TEMP
  • RMAN introduces compression for backups
  • New drop database syntax
  • New alter database begin backup syntax
  • Oracle10g Data Guard Broker introduced
  • Oracle10g RAC supports secure Redo Log transport
  • Flashback enhancements for flashback database and flashback table syntax
  • SQL Apply feature
  • VPD (FGAC, RLS) supports both row-level and column-level VPD
  • Cross Platform Transportable Tablespaces
  • External Table unload utility
  • SQL Regular Expression Support with the evaluate syntax
  • New ROW TIMESTAMP column
  • Improvement to SSL handshake speed
  • Automatic Database Tuning of Checkpoints, Undo Segments and shared memory
  • Automated invoking of dbms_stats for CBO statistics collection
  • RAC introduces Integrated Cluster ware
  • Oracle Application Builder supports HTML DB
  • Browser Based Data Workshop and SQL Workshop
  • PL/SQL Compiler enhanced for compile-time Warnings in utl_mail and utl_compress
  • VPD (FGAC, RLS) supports both row-level and column-level VPD
  • External Table unload utility
  • SQL Regular Expression Support with the evaluate syntax
  • New ROW TIMESTAMP column

 

Oracle SQL Tuning Goals

Oracle SQL tuning goals

Oracle SQL tuning is a phenomenally complex subject. Entire books have been written about the nuances of Oracle SQL tuning; however, there are some general guidelines that every Oracle DBA follows in order to improve the performance of their systems.  Again, see the book “Oracle Tuning: The Definitive Reference“, for complete details.

The goals of SQL tuning focus on improving the execution plan to fetch the rows with the smallest number of database “touches” (LIO buffer gets and PIO physical reads). 

  • Remove unnecessary large-table full-table scans—Unnecessary full-table scans cause a huge amount of unnecessary I/O and can drag-down an entire database. The tuning expert first evaluates the SQL based on the number of rows returned by the query. The most common tuning remedy for unnecessary full-table scans is adding indexes. Standard b-tree indexes can be added to tables, and bitmapped and function-based indexes can also eliminate full-table scans. In some cases, an unnecessary full-table scan can be forced to use an index by adding an index hint to the SQL statement.
     
  • Cache small-table full-table scans—In cases where a full-table scan is the fastest access method, the administrator should ensure that a dedicated data buffer is available for the rows.  In Oracle8 and beyond, a small table can be cached by forcing it into the KEEP pool.
     
  • Verify optimal index usage—Oracle sometimes has a choice of indexes, and the tuning professional must examine each index and ensure that Oracle is using the proper index.
     
  • Materialize your aggregations and summaries for static tables – One features of the Oracle 10g SQLAccess advisor is recommendations for new indexes and suggestions for materialized views.  Materialized views pre-join tables and pre-summarize data, a real silver bullet for data mart reporting databases where the data is only updated daily. Again, see the book “Oracle Tuning: The Definitive Reference“, for complete details on SQL tuning with materialized views.

These are the goals of SQL tuning in a nutshell. However, they are deceptively simple, and to effectively meet them, we need to have a through understanding of the internals of Oracle SQL. Let’s begin with an overview of the Oracle SQL optimizers.

Database Triggers

A trigger is PL/SQL code block attached and executed by an event which occurs to a database table. Triggers are implicitly invoked by DML commands. Triggers are stored as text and compiled at execute time, because of this it is wise not to include much code in them but to call out to previously stored procedures or packages as this will greatly improve performance. You may not use COMMIT, ROLLBACK and SAVEPOINT statements within trigger blocks. Remember that triggers may be executed thousands of times for a large update – they can seriously affect SQL execution performance

Triggers may be called BEFORE or AFTER the following events :-

INSERT, UPDATE and DELETE.

Triggers may be STATEMENT or ROW types. STATEMENT triggers fire BEFORE or AFTER the execution of the statement that caused the trigger to fire. ROW triggers fire BEFORE or AFTER any affected row is processed.