Saturday, December 25, 2010

How to Open the Encryption Wallet Automatically When the Database Starts

Whenever you startup the database the wallet are not open automatically. DBA or security manager must invoke command "alter system set wallet open identified by pass" manually to open the wallet otherwise query on the encrypted table will fail with ORA-28365: wallet is not open. You really might want to open the wallet automatically when the database startup. The following steps will help you to open the wallet automatically when the database starts.

Step 01: Create a file tde.sql with the following code:
create or replace procedure open_wallet
as
wallet_open exception;
pragma exception_init(wallet_open,-28000);
v_stmt varchar2(100);
v_password varchar2(20);
begin
  -- edit the following line to store your secret wallet password
  v_password := 'PASS';
  v_stmt :='ALTER SYSTEM SET WALLET OPEN IDENTIFIED BY  "'||v_password||'"';
  execute immediate v_stmt ;
 exception
  when wallet_open then
    null;
end;
/

Step 02: Wrap the code in tde.sql file.
C:\>wrap iname=D:\oracle\admin\A\tde.sql

PL/SQL Wrapper: Release 10.2.0.3.0- Production on Sun Dec 26 12:15:24 2010

Copyright (c) 1993, 2004, Oracle.  All rights reserved.

Processing D:\oracle\admin\A\tde.sql to tde.plb
Delete the tde.sql file after you have created the wrapped version!

Step 03: Create the wrapped procedure by running tde.plb
C:\>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.3.0 - Production on Sun Dec 26 12:18:04 2010

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> @tde.plb

Procedure created.
Step 04: Create an event trigger that calls the procedure when the database starts.

create or replace trigger open_tde_wallet
after startup on database
begin
-- call wrapped pl/sql pocedure
sys.open_wallet;
end;
/

Output:
SQL> create or replace trigger open_tde_wallet
  2  after startup on database
  3  begin
  4  -- call wrapped pl/sql pocedure
  5  sys.open_wallet;
  6  end;
  7  /

Trigger created. 

Step 05: Test by restarting your database.
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area  314572800 bytes
Fixed Size                  1290328 bytes
Variable Size             272633768 bytes
Database Buffers           33554432 bytes
Redo Buffers                7094272 bytes
Database mounted.
Database opened.
SQL> select * from arju.payment_info;

CUST_ID      CREDIT_CARD_NO
------------ --------------------
1            67787676789

Husband and wife's salary day

I found this fun interesting and so shared it inside my blog.
1)Wife:Where is your salary.
Wife:Where is your salary.

2)Wife:Show me Your pockets.
Wife:Show me Your pockets.

3)Husband :I 'll not give u money.....U will spend all of my salary.
Husband :I 'll not give u money.....U will spend all of my salary.

4)Wife:Whatever .......I am going for shopping.
Wife:Whatever .......I am going for shopping.

5)Wife:Thank u sweetheart.....................Bye
Wife:Thank u sweetheart.....................Bye

Database Schema for Object-Relational OO7SubDB

Tables Script
DROP TABLE REL_BASEASSEMBLY CASCADE CONSTRAINTS;
DROP TABLE REL_COMPLEXASSEMBLY CASCADE CONSTRAINTS;
DROP TABLE REL_COMPONENTSSHAR CASCADE CONSTRAINTS;
DROP TABLE REL_COMPOSITEPART CASCADE CONSTRAINTS;
DROP TABLE REL_MODULE CASCADE CONSTRAINTS;

CREATE TABLE Rel_Module (
 Id NUMBER (6) PRIMARY KEY, 
 Type CHAR (7) NOT NULL, 
 BuildDate NUMBER (4) NOT NULL, 
 Designroot NUMBER (6) NOT NULL)
/
CREATE TABLE REL_ComplexAssembly (
 Id NUMBER (6) PRIMARY KEY, 
 Type CHAR (7) NOT NULL, 
 BuildDate NUMBER (4) NOT NULL, 
 SuperAssemId NUMBER (6), 
ModId NUMBER (6) NOT NULL)
/
CREATE TABLE REL_BaseAssembly (
 Id NUMBER (6) PRIMARY KEY, 
 Type CHAR (7) NOT NULL, 
 BuildDate NUMBER (4) NOT NULL, 
 SuperAssemId NUMBER (6), 
 ModId NUMBER (6) NOT NULL)
/
CREATE TABLE REL_CompositePart (
 Id NUMBER (6) PRIMARY KEY, 
Type CHAR (7) NOT NULL,
BuildDate NUMBER (4) NOT NULL)
/
CREATE TABLE REL_ComponentsShar (
 ComPartId NUMBER (6) NOT NULL REFERENCES REL_CompositePart (Id), 
 BaseId NUMBER (6) NOT NULL REFERENCES REL_BaseAssembly (Id))
/


Constraints
ALTER TABLE REL_Module ADD CONSTRAINT FKEY_DESIGNROOT FOREIGN KEY 
(Designroot) REFERENCES REL_ComplexAssembly (Id) DEFERRABLE
/
ALTER TABLE REL_ComplexAssembly ADD CONSTRAINT FKEY_COMSUPASSID 
FOREIGN KEY (SuperAssemId) REFERENCES REL_ComplexAssembly (Id) DEFERRABLE
/
ALTER TABLE REL_ComplexAssembly ADD CONSTRAINT FKEY_COMMODID 
FOREIGN KEY (ModId) REFERENCES REL_Module (Id) DEFERRABLE
/
ALTER TABLE REL_BaseAssembly ADD CONSTRAINT FKEY_BASMODID 
FOREIGN KEY (ModId) REFERENCES REL_Module (Id) DEFERRABLE
/
ALTER TABLE REL_BaseAssembly ADD CONSTRAINT FKEY_BASSUPASSID 
FOREIGN KEY (SuperAssemId) REFERENCES REL_ComplexAssembly (Id) DEFERRABLE
/

Oracle Assignment - Implementing Object-Relational OO7SubDB

Section 1)            Scenarios and Tasks


A.          Part 1         (60 marks) LOs 2 & 3

1.           Scenario: OO7SubDB


OO7 Benchmark (Carey, DeWitt and Naughton, 1994) has been used widely for performance evaluation of object-based database systems. Figure 1 shows a subset of the conceptual model of the OO7 database (henceforth referred to as OO7SubDB).


Figure 1: UML Class Diagram for the OO7SubDB’s Conceptual Model


In OO7SubDB, DesignObj is the root in the class hierarchy for most of the objects in the database because it models the common state that is inherited by Module, Assembly, and CompositePart classes.  From a modelling perspective, a Module is a top-level object that contains all the other objects. In other words, creating an instance of Module requires, depending on certain parameters defined in the OO7 Benchmark, creating objects in the following hierarchical manner for a small size database:

·         1093 Assembly objects out of which 729 are BaseAssembly objects and 364 ComplexAssembly objects. These objects are arranged in seven levels such that the bottom level is made up of BaseAssembly objects (each of which is connected underneath to three shared CompositePart objects, and to a ComplexAssembly on top and the remaining six levels are composed of ComplexAssembly objects.
·         500 CompositePart objects


Figure 2: Organization of Objects in the OO7 database

Figure 2 shows how objects are organized in the OO7SubDB. The first ComplexAssembly object (e.g. having id of 1 or 365) of each Module (currently there are 2 module objects in the database) is designated as designRoot. Moreover, for each Module object, there are 500 CompositePart objects created in the database. That is if a Module object is created whose id is 1 then 500 CompositePart objects are created with unique ids ranging from 1 to 500. Similarly, if a Module object is created with id equal to 2 then 500 CompositePart objects are created with unique ids ranging from 501 to 1000.

2.           Relational Implementation of OO7SubDB


A conceptual model of a database may be implemented using any database system (e.g. relational, object-relational, object-oriented). However, to start with, we have mapped the OO7SubDB’s conceptual model onto a relational logical model. The Oracle SQL code that implements the logical model of the OO7SubDB is given in Figure 3.

CREATE TABLE Rel_Module (
      Id NUMBER (6) PRIMARY KEY,
      Type CHAR (7) NOT NULL,
      BuildDate NUMBER (4) NOT NULL,
      Designroot NUMBER (6) NOT NULL);

CREATE TABLE REL_ComplexAssembly (
      Id NUMBER (6) PRIMARY KEY,
      Type CHAR (7) NOT NULL,
      BuildDate NUMBER (4) NOT NULL,
      SuperAssemId NUMBER (6),
ModId NUMBER (6) NOT NULL,
AssmType NUMBER(1));

CREATE TABLE REL_BaseAssembly (
      Id NUMBER (6) PRIMARY KEY,
      Type CHAR (7) NOT NULL,
      BuildDate NUMBER (4) NOT NULL,
      SuperAssemId NUMBER (6),
      ModId NUMBER (6) NOT NULL,
AssmType NUMBER(1));

CREATE TABLE REL_CompositePart (
      Id NUMBER (6) PRIMARY KEY,
Type CHAR (7) NOT NULL,
BuildDate NUMBER (4) NOT NULL)

CREATE TABLE REL_ComponentsShar (
      ComPartId NUMBER (6) NOT NULL REFERENCES REL_CompositePart (Id),
      BaseId NUMBER (6) NOT NULL REFERENCES REL_BaseAssembly (Id));

ALTER TABLE REL_Module ADD CONSTRAINT FKEY_DESIGNROOT FOREIGN KEY
(Designroot) REFERENCES REL_ComplexAssembly (Id);

ALTER TABLE REL_ComplexAssembly ADD CONSTRAINT FKEY_COMSUPASSID
FOREIGN KEY (SuperAssemId) REFERENCES REL_ComplexAssembly (Id);

ALTER TABLE REL_ComplexAssembly ADD CONSTRAINT FKEY_COMMODID
FOREIGN KEY (ModId) REFERENCES REL_Module (Id);

ALTER TABLE REL_BaseAssembly ADD CONSTRAINT FKEY_BASMODID
FOREIGN KEY (ModId) REFERENCES REL_Module (Id);

ALTER TABLE REL_BaseAssembly ADD CONSTRAINT FKEY_BASSUPASSID
FOREIGN KEY (SuperAssemId) REFERENCES REL_ComplexAssembly (Id);
Figure 3: Relational Schema of OO7SubDB

3.           Accessing the relational OO7SubDB


If you are working on the assignment on Campus using the School’s PCs and the INFORMATICS database, then you can access the relational version of OO7SubDB using OO7RDB.TableName format. For example, to retrieve data from the Module table, use:

SELECT * FROM OO7RDB.Rel_Module;


TASKS

 Implementing Object-Relational OO7SubDB                    (24 MARKS)



Implement the OO7SubDB using object-relational (OR) features of Oracle 9i/10g. You need to discuss your approach to the implementation (4 marks) and provide complete code (20 marks).

Note that all relationships (e.g. one-to-one, one-to-many, many-to-many) must be bi-directional. Moreover, each to-many side of a relationship (e.g., in case of many-to-one and many-to-many) should be implemented using nested tables. In addition, your implementation should allow all objects to be shareable (i.e. all relationships should be REF based).

Also note that if a domain of an attribute/column is a nested table, before you insert any data in the nested tables of some objects, you must initialise the nested tables to a default empty nested table. For example, consider the following code:

CREATE TYPE Movie AS OBJECT (
            Title varchar(15), Year  number(4,0),            
Lenght number(3, 0));
/

CREATE TYPE Movie_Tab AS TABLE OF REF Movie;
/
CREATE TABLE Star (
            Name varchar(15),
Movies  Movie_Tab)
            NESTED TABLE Movies STORE AS Star_Movie;



Suppose that you have created Star objects without values for nested table column Movies. Before you can insert data into Movies nested table column of Star objects, you must run the following:

UPDATE STAR
SET Movies = Movie_Tab();
COMMIT;

In the above statement Movie_Tab() is a literal invocation of the constructor method for an empty Movie_Tab table. Alternatively, one can define DEFAULT value for object-valued columns. For example:

CREATE TABLE Star (
            Name Varchar(15),
Movies  Movie_Tab DEFAULT Movie_Tab())
            NESTED TABLE Movies STORE AS Star_Movie;

Oracle (2005) provides more detailed documentation on Oracle object-relational features.


                  Populating the OR version of OO7SubDB   (24 MARKS)



Populate your OR version of OO7SubDB using data from its relational implementation. This part can be seen to contain the following sub-tasks:

a) Loading scalar data into the object tables
b) Establishing one-to-one, one-to-many, many-to-one (also many-to-many) relationships

NOTE the following important points:

·         All the data that you will need to populate your OR database is available from the shared database called OO7RDB. You do not need to generate/construct your own data set.
·         You can make use of SQL and PL/SQL (e.g., Procedures, Functions, and Triggers).
·         In your assignment report, you must discuss how the data is loaded into the OR version of the database providing all the code used for populating the OR database.
·         Discussion about the choices you made and the approach you used for populating the database is worth 4 marks whereas the code is worth 20 marks.



     Writing SQL Queries   (12 MARKS)


For this part, you can use SQL or PL/SQL code, whichever is appropriate or applicable.
Answer the following questions after populating the object-relational database (after completing part 4.2):

Q a) Retrieve the details of the CompositePart objects that have been associated with the maximum number of Assembly objects (4 marks).

(i)            Answer the query over the relational implementation of OO7SubDB.
(ii)          Answer the query over your OR implementation of OO7SubDB.
(iii)         Compare and contrast your answers to (i) and (ii).

Note that if you want to compare the performance of these queries you will need to run the following from the SQL* Plus prompt:

SET TIMING ON

Subsequently, whenever you run any query during that session, elapsed time will be displayed on the prompt, which can give you an idea of the efficiency of answering queries over the relational and object-relational implementation of OO7SubDB.



Q b) Find out the total number of all objects of the DesignObj type (2 marks).

Note that in object-based databases (i.e. object-relational and object-oriented) an “extent” of a class is a set containing all of its instances. Theoretically, the extent of a super-type/super-class subsumes the extent of all of its sub-types/sub-classes. For example, if Student and Lecturer are sub-classes of Person class and there are 500 students and 20 lecturers then we can say that there are 520 persons in the database.

Q c) Find out details of the top-10 DesignObj objects in ascending order of id and descending order of buildDate. The details should include id, type, buildDate and the specific object type (e.g. Module, BaseAssembly, CompositePart, etc) of each selected object (3 marks).

Note that in the object-based database literature (also in object-oriented programming languages) it is legitimate to use an instance of a sub-class where an instance of its super-class is expected i.e. the notion of substitutability.
Q d) Write a brief report (not more than one A4 size page) reflecting on your experiences of creating, populating and querying the object-relational database (3 marks).

You should reflect on the work you have done so far on the assignment including the above queries. You can talk about how effectiveness and usefulness of the knowledge and skills you have learned by doing all the preceding tasks of the assignment. You can also comment on the object-relational features of Oracle 9i/10g. Moreover, you may choose to discuss the sorts of activities one would perform in implementing the same database using relational database technology as opposed to the object-relational technology that you have been using in solving the assignment.


Part 2         (16 marks) LOs 3 & 5


In this task, you need to demonstrate the use of multimedia features of Oracle 10g to define a multimedia database for a company selling DVDs containing music. The requirements are as follows:

The company needs to store information on:
  • musical works (serial number, title, composer, soloist, date recorded, short description (up to 256 bytes), long description (up to 32KB), playing time, sample clip, full recording)
  • composer details(composer, date born, date died, biography, sample clip)
  • soloist details(soloist, date born, date died, biography, sample clip)

Where appropriate, you should use object-relational features in Oracle 9i/10g for constructing your data structures. You may consider that REF-based foreign keys are an appropriate way for representing relationships. You may assume that there is one composer and one performer for each work so nesting does not need to be considered in this part.

 Part 3         (24 marks) LO 4

In this part, you will demonstrate the application of interoperability/distributed databases. Two companies have independently established databases on residential telephone numbers, types of telephone and their owners as given below in relational definitions for databases A and B.

Database A

Tel_number (tel_id, country_code, city_code, user_number)
Owner (person_id, name, house_name, street, city, postcode)
Tel_owned (tel_id*, person_id*)
Tel_type (tel_id*, manufacturer, LCD, buttons, other_properties)

Database B

Tel_number (tel_id, town_code, number, tel_type)
Owner (person_id, name, address, postcode, tel_id*)

Primary keys are indicated by underlining and foreign keys by an *. You may assume that attributes with the same name are of the same type and that the names given have their natural meaning.

Your tasks are as follows:

1.    For the purposes of interoperability, it is desirable to determine the metadata and meta-meta data for an application. Give both the meta- and meta-meta data for each database above and comment on significant differences.

2.    What techniques may be used to explore the metadata in an attempt to achieve interoperability?


Hand In procedure

The answer should be in the form of a textual document, which MUST be printed out and submitted as hard copy. You must also provide your assignment together will all the script and output files electronically on a CD. Any part of your work, which is not provided in printed form will not be considered for marking.


Database schema is provided in http://arjudba.blogspot.com/2010/12/database-schema-for-object-relational.html

ORA-28365: wallet is not open

Problem Description
Whenever we try to import an encrypted table which was encrypted by transparent data encryption, it fails with ORA-39180, ORA-28365: wallet is not open.
C:\>impdp userid=arju/a tables=arju.payment_info ENCRYPTION_PASSWORD="ANY_PASSWORD" dumpfile=encrypted_dump.dmp

Import: Release 10.2.0.3.0 - Production on Saturday, 25 December, 2010 16:39:20

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-39001: invalid argument value
ORA-39180: unable to encrypt ENCRYPTION_PASSWORD
ORA-28365: wallet is not open

Similarly when DBA explicitly close wallet then query on encrypted table fails with ORA-28365.
SQL> alter system set wallet close;

System altered.

SQL> select * from payment_info;
select * from payment_info
              *
ERROR at line 1:
ORA-28365: wallet is not open

Cause of the Problem
As the error message shown, the problem arises because of wallet is not open.

Solution of the Problem
Open the wallet by following command.
SQL> alter system set wallet open identified by pass;

System altered.

Then issue import command again.
C:\>impdp userid=arju/a tables=arju.payment_info ENCRYPTION_PASSWORD="ANY_PASSWORD" dumpfile=encrypted_dump.dmp

Import: Release 10.2.0.3.0 - Production on Saturday, 25 December, 2010 16:40:42

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "ARJU"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "ARJU"."SYS_IMPORT_TABLE_01":  userid=arju/******** tables=arju.payment_info encryption_password=******** dumpfile=encrypted_dump.dmp
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "ARJU"."PAYMENT_INFO"                       5.304 KB       1 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "ARJU"."SYS_IMPORT_TABLE_01" successfully completed at 16:40:44

Friday, December 24, 2010

impdp fails with ORA-39174 or ORA-39176

You have transparent data encryption feature enabled in your database. You took your dump with expdp utility with the ENCRYPTION_PASSWORD parameter. Now whenever you try to import your dump without ENCRYPTION_PASSWORD parameter you will get ORA-39174 error. Following is the case.
C:\>impdp userid=arju/a tables=arju.payment_info  dumpfile=encrypted_dump.dmp

Import: Release 10.2.0.3.0 - Production on Friday, 24 December, 2010 20:34:00

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: invalid operation
ORA-39174: Encryption password must be supplied.
The solution of ORA-39174 problem can be easily solved by adding ENCRYPTION_PASSWORD parameter. Following is the output where we have added ENCRYPTION_PASSWORD parameter but the value of password is wrong and which leads to ORA-39176 error.

C:\>impdp userid=arju/a tables=arju.payment_info ENCRYPTION_PASSWORD="any_password" dumpfile=encrypted_dump.dmp

Import: Release 10.2.0.3.0 - Production on Friday, 24 December, 2010 20:34:27

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: invalid operation
ORA-39176: Encryption password is incorrect.

If you provide correct password then data will be imported successfully.
C:\>impdp userid=arju/a tables=arju.payment_info ENCRYPTION_PASSWORD="ANY_PASSWORD" dumpfile=encrypted_dump.dmp

Import: Release 10.2.0.3.0 - Production on Saturday, 25 December, 2010 11:28:51

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "ARJU"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "ARJU"."SYS_IMPORT_TABLE_01":  userid=arju/******** tables=arju.payment_info encryption_password=******** dumpfile=encrypted_dump.dmp
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "ARJU"."PAYMENT_INFO"                       5.304 KB       1 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "ARJU"."SYS_IMPORT_TABLE_01" successfully completed at 11:28:55

ORA-39173: Encrypted data has been stored unencrypted in dump file set

Problem Description
Oracle Data pump export reports error ORA-39173 like below.
.
.
exported "TSMSYS"."SRS$" 0 KB 0 rows
ORA-39173: Encrypted data has been stored unencrypted in dump file set.
Master table  "EXPDP_DBA"."SYS_EXPORT_FULL_01" successfully  loaded/unloaded
******************************************************************************
Dump  file set for EXP_DBA.SYS_EXPORT_FULL_01  is:
/backup/DUMP/expdp/DUMP_20101219_230011.dmp
Job  "EXPDP_DBA"."SYS_EXPORT_FULL_01" completed with 1 error(s) at 23:36:50

Cause of the Problem
I would better say this is oracle warning rather than error message. You can still use the dump file for import operation but the encrypted table data within the dump file remain unencrypted.

Solution of the Problem
If you want to avoid warning message then add the ENCRYPTION_PASSWORD parameter with your expdp command. If you supply ENCRYPTION_PASSWORD="TEST" then data within the dumpfile of the encrypted table will be remain encrypted and so no warning message will be generated. However, you can simply ignore the warning message if you don't want to encrypt the table columns.

Thursday, December 23, 2010

How to export table containing encrypted columns

Let'e first check whether database has any encrypted columns or not by querying dba_encrypted_columns view.
SQL> set linesize 150
SQL> col owner for a8
SQL> select * from dba_encrypted_columns;

OWNER    TABLE_NAME                     COLUMN_NAME                    ENCRYPTION_ALG                SAL
-------- ------------------------------ ------------------------------ ----------------------------- ---
ARJU     PAYMENT_INFO                   CREDIT_CARD_NO                 AES 192 bits key              NO

Also, check the data of the encrypted columns.
SQL> select * from arju.payment_info;

CUST_ID      CREDIT_CARD_NO
------------ --------------------
1            67787676789
Let's try to export the table now. We must use data pump export utility that is expdp as original export utility exp can't export encrypted table data. While using expdp utility we have the option whether within the dump file we want to keep encrypted table columns data as encrypted or not. The parameter ENCRYPTION_PASSWORD allows the encrypted columns to be exported as encrypted. If we don't use ENCRYPTION_PASSWORD parameter then data within dumpfile will not be encrypted and then anyone can import the data in any database.

Note that, while using expdp we can use any password with the ENCRYPTION_PASSWORD parameter. During import operation that password need to use with the ENCRYPTION_PASSWORD parameter if we want to restore encrypted columns table data.

Following is the valid command to export encrypted table arju.payment with password "ANY_PASSWORD". The double quote around it preserves letter case.
C:\>expdp userid=arju/a tables=arju.payment_info ENCRYPTION_PASSWORD="ANY_PASSWORD" dumpfile=encrypted_dump.dmp

Export: Release 10.2.0.3.0 - Production on Friday, 24 December, 2010 13:01:03

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "ARJU"."SYS_EXPORT_TABLE_01":  userid=arju/******** tables=arju.payment_info encryption_password=******** dumpfile=encrypted_dump.dmp
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "ARJU"."PAYMENT_INFO"                       5.304 KB       1 rows
Master table "ARJU"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ARJU.SYS_EXPORT_TABLE_01 is:
  D:\ADMIN\A\DPDUMP\ENCRYPTED_DUMP.DMP
Job "ARJU"."SYS_EXPORT_TABLE_01" successfully completed at 13:01:24

Remember that the encrypted values can ONLY BE DECRYPTED with the master key which is stored in the WALLET file. So which taking export, DO NOT FORGET to backup the wallet file with the export.

EXP-00107: Feature (COLUMN ENCRYPTION) of column is not supported

Problem Description
While exporting encrypted table using oracle export utility it fails with EXP-00107 error and encrypted table is not exported.
C:\>exp tables=payment_info userid=arju/a

Export: Release 10.2.0.3.0 - Production on Thu Dec 23 15:57:59 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
EXP-00107: Feature (COLUMN ENCRYPTION) of column CREDIT_CARD_NO in table ARJU.PAYMENT_INFO is not supported. The table will not be exported.
Export terminated successfully with warnings.

Cause of the Problem
Oracle original export utility (exp) does not support transparent data encryption and hence it can't export encrypted column tables.

Solution of the Problem
If you have TDE enabled table then to export that table you have to use Data Pump export utility (expdp). TDE is only compatible with DataPump export and DataPump import.
For example, you have to issue following command:
C:\>exp tables=payment_info userid=arju/a ENCRYPTION_PASSWORD=a

Wednesday, December 22, 2010

ORA-28368: cannot auto-create wallet ORA-28353: failed to open wallet

Problem Description
Oracle is extremely buggy database and it always add new features without any testing. In Oracle version 10gR2 it has implemented new feature Transparent Data Encryption (TDE). To implement the feature whenever I try to create the encrypted wallet file using following command ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY ... it fails with ORA-28368 or ORA-28353.
SQL> ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY pass;
ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY pass
*
ERROR at line 1:
ORA-28368: cannot auto-create wallet
or,
SQL> ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY "pass";
ALTER SYSTEM SET ENCRYPTION KEY IDENTIFIED BY "pass"
*
ERROR at line 1:
ORA-28353: failed to open wallet
Cause of the Problem
In a word this is Oracle bug. Oracle identifies it as bug Bug 5551624 when ORA-28353 can occur creating a Wallet on 64bit platforms. But I see error happens on 32 but platforms as well. This error will also be reported if you don't have wallet folder inside default wallet installation directory $ORACLE_BASE/admin/$ORACLE_SID. The default location may not work on some 64 bit platforms.

Solution of the Problem
Solution 01:
Create WALLET directory in the location of $ORACLE_BASE/admin/$ORACLE_SID directory. For example if your ORACLE_BASE is set to D:\ drive on windows machine and ORACLE_SID is A then you must have the directory D:\admin\a\WALLET. If not, create it. After you create it run the auto creating wallet command again.

Solution 02:
This bug is fixed on Oracle 10.2.0.4 (Server Patch Set) and 11.1.0.6 (Base Release). So upgrading your Oracle to newer version is a solution.

Solution 03:
Specify the location of the wallet file (which is used to store the encryption master key) explicitly by adding the following entry in $ORACLE_HOME/network/admin/sqlnet.ora:
ENCRYPTION_WALLET_LOCATION=
          (SOURCE=(METHOD=FILE)(METHOD_DATA=
                  (DIRECTORY=D:\Oracle\product\admin\wallet)))
After you set it inside sqlnet.roa make sure the directory exists on the filesystem and is accessible by the oracle software owner.
Check permission on the folder and issue your command again.

RMAN backup Fails with ORA-19510 and ORA-27046

Problem Description
RMAN backup failed with error message RMAN-03009, ORA-19510 and ORA-27046.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on channel1 channel at 20/12/2010 01:22:21
ORA-19510: failed to set size of 262143 blocks for file "/backup/database/prod/hot_backup.rman" (blocksize=)
ORA-27046: file size is not a multiple of logical block size
Additional information: 2

Cause of the Problem
Note that, there are several variants of this ORA-19510 error. You can search for ORA-19510 within my blog. In this case problem started due to the operating system size limit. RMAN backup piece size exceed the max file size limit of the O/S.

Solution of the Problem
Make sure that rman backup piece won't exceed the O/S permitted filesize limit. You can restrict the rman backup piece using the MAXPIECESIZE option.
For example in RMAN prompt issue,

RMAN> Configure channel device type disk MAXPIECESIZE = 2G;
And then run your backup command again.

RMAN> backup database ;

Monday, December 20, 2010

ORA-19510, ORA-27044 HP-UX Error: 2: No such file or directory

Problem Description
While taking RMAN backup it fails with following message.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on channel1 channel at 12/20/2010 01:30:21
ORA-19510: failed to set size of 6410 blocks for file "/backup/PROD_DATABASE/rman/PROD_tdatabase_s2398_LVL_1" (blocksize=8192)
ORA-27044: unable to write the header block of file
HP-UX Error: 2: No such file or directory
Additional information: 7
ORA-19510: failed to set size of 4294967295 blocks for file "/backup/PROD_DATABASE/rman/PROD_tdatabase_s2398_LVL_1" (blocksize=8192)
ORA-27044: unable to write the header block of file


Cause of the Problem
The backup fails as there is no space available on the disk.

Solution of the Problem
Check the space where you are taking RMAN backup. For example, in this case we see backup is generated in the location /backup/PROD_DATABASE/rman/ so check disk space usage or free disk space remained into /backup partition. You can check space usage on unix file system by using du -sh * comamnd. You can also issue,
$df -h
to see free space available.
In order to take backup you need to delete unnecessary files from the partition.

RMAN-03009, ORA-19510, ORA-27037, IBM AIX RISC System/6000 Error

Problem Description
While taking RMAN backup it fails with following errors:
RMAN-03009: failure of backup command on DISK1 channel at 09/19/2005 19:51:02
ORA-19510: failed to set size of 268930 blocks for file
"/backup/rman/backup/full/rman_complete_backup" (blocksize=8192)
ORA-27037: unable to obtain file status
IBM AIX RISC System/6000 Error: 2: No such file or directory
Additional information: 5
Cause of the Problem
The problem occurred because backup piece is being removed from disk before the backup finished. That means backup piece is deleted before RMAN completely finishes creating it. In fact there was a scheduled cron purge job that conflicted with the RMAN backup and was removing the piece before RMAN finished creating it.

Solution of the Problem
The solution is schedule the cron purge job to run at a different time to allow the RMAN backup job to complete or remove the cron purge job entirely.

Sunday, December 19, 2010

ORA-39097, ORA-39065, ORA-31643, ORA-19510, ORA-27045 Linux-x86_64 Error: 5

Problem Description
Oracle data pump export operation on 10.2.0.4 database into CIFS file system fails with error ORA-39097, ORA-39065, ORA-31643, ORA-19510, ORA-27045 Linux-x86_64 Error: 5.
ORA-39097: Data Pump job encountered unexpected error -31643
ORA-39065: unexpected master process exception in FILE
ORA-31643: unable to close dump file "/backup/oracle/Datapump/data_pump.dmp"
ORA-19510: failed to set size of 1 blocks for file "/backup/oracle/Datapump/data_pump.dmp"
(blocksize=4096)
ORA-27045: unable to close the file
Linux-x86_64 Error: 5: Input/output error
Additional information: 4

Cause of the Problem
The errors occurred as Oracle data pump does not support CIFS file system. Though in the Oracle documentation it is not specified and after searching in metalink it is identified this case as Oracle Bug 8313127.

Solution of the Problem
As Oracle data pump does not support CIFS file system so export dump file to something else file system. For example take data pump export into NFS file system.