Search Articles

Hash Partitioning with Examples in Oracle

Hash partitioning is a partitioning technique where a hash key is used to distribute rows evenly across the different partitions. Hash partitioning is used where ranges aren't appropriate, i.e. employee number, customer ID, etc. Using this approach, data is randomly distributed across the partitions rather than grouped.


How to Create Hash Partition Table in Oracle

  • Choose a column that is unique.
  • Create multiple partitions and subpartitions for each partition that is a power of two. For example, 2, 4, 8, 16, 32, 64, 128, and so on.



Following are the Benefits and uses of Hash Partitioning:

  1. To enable partial or full parallel partition-wise joins with likely equisized partitions.
  2. To distribute data evenly among different partitions.
  3. To use partition pruning and partition-wise joins according to a partitioning key that is mostly constrained by a distinct value or value list.
  4. To randomly distribute data to avoid I/O bottlenecks if you do not use a storage management technique that stripes and mirrors across all available devices.


Examples to Create Hash Partition Table in Oracle

CREATE TABLE CUSTOMERS
(
RECEIVED_TIME_STAMP     DATE NOT NULL,
NETWORK_ID              VARCHAR2(10) NOT NULL,
RECORD_TYPE             VARCHAR2(50),
CUSTOMER_ID             NUMBER(18) NOT NULL,
PHONE_NUMBER            VARCHAR2(80),
CUSTOMER_NAME           VARCHAR2(80),
ACCOUNT_ID              NUMBER(18),
CUSTOMER_TYPE           VARCHAR2(80),
NRC_NUMBER              VARCHAR2(80),
CUSTOMER_FIRST_NAME     VARCHAR2(80),
CUSTOMER_MIDDLE_NAME    VARCHAR2(80),
CUSTOMER_LAST_NAME      VARCHAR2(80)
)
partition BY hash (CUSTOMER_ID)
(
partition PARTITION P001 tablespace TS_CUSTOMERS_01,
partition PARTITION P002 tablespace TS_CUSTOMERS_02,
partition PARTITION P003 tablespace TS_CUSTOMERS_03,
partition PARTITION P004 tablespace TS_CUSTOMERS_04,
partition PARTITION P005 tablespace TS_CUSTOMERS_01,
partition PARTITION P006 tablespace TS_CUSTOMERS_02,
partition PARTITION P007 tablespace TS_CUSTOMERS_03,
partition PARTITION P008 tablespace TS_CUSTOMERS_04,
partition PARTITION P009 tablespace TS_CUSTOMERS_01,
partition PARTITION P010 tablespace TS_CUSTOMERS_02,
partition PARTITION P011 tablespace TS_CUSTOMERS_03,
partition PARTITION P012 tablespace TS_CUSTOMERS_04,
partition PARTITION P013 tablespace TS_CUSTOMERS_01,
partition PARTITION P014 tablespace TS_CUSTOMERS_02,
partition PARTITION P015 tablespace TS_CUSTOMERS_03,
partition PARTITION P016 tablespace TS_CUSTOMERS_04
);


Example to Create Index on the above Partition Table

CREATE  INDEX IX_CUSTOMER_ID on CUSTOMERS (CUSTOMER_ID) INITRANS 4 STORAGE(FREELISTS 16)
LOCAL
(
PARTITION P001 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P002 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P003 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P004 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P005 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P006 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P007 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P008 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P009 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P010 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P011 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P012 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P013 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P014 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P015 TABLESPACE TS_CUSTOMER_ID_IDX,
PARTITION P016 TABLESPACE TS_CUSTOMER_ID_IDX
);
Read more ...

How to Share Windows Drives and Folders using Oracle VM VirtualBox With a Guest Linux OS

There are several virtual machine available in the market for free use. Oracle VM VirtualBox is one of it which enables you to deploy operating system and application software with supported virtualization environment. It is freely available for Windows, Mac OS X, Linux and Solaris x-86 platforms under GPLv2.  However, the main functionality of all VMs are the same.  The host operating system can support a number of virtual machines, each of which has the characteristics of a particular OS. The kernel manages all system resources and tasks, including process scheduling, memory, disk space, and processor time.

Download VM 



share windows folder with oracle vmware virtual machine



Once vmware is downloaded, you can install and setup your Guest OS. However, sharing host drives\folders is one of the tricky task and is not as simple as clicking and enabling sharing in windows. During my VM setup there was a need to mount and share windows folder which should be accessible from Linux OS. I went through many articles and finally able to mount windows folders to the Linux OS which was running on the top of VM.


Below are the steps by step guide using which you will be able to mount any folders or Drives.



STEP 1: 

Run host OS and launch VM VirtualBox.


STEP 2:

Start Linux box which you have installed in VM.


STEP 3:

Click on "Devices" tab which is located on the top of VM VirtualBox taskbar and select "Shared Folders" from the drop-down list.






STEP 4:

VirtualBox will open a window "Shared Folders". Click on the top icon in the right-hand corner to add the drive/folder. Another window will open—"Add Share".



Step 5:

You can also type the name of the folder in the "Folder Name" box. It can be any name you wish to have on Guest OS. Also, check the boxes "Auto Mount" and "Make Permanent" and click "OK".




STEP 7:

To mount shared folders in linux machine, Login to Linux box and type the below command 


$ mount -t vboxsf Softi /media

HERE Softi is the shared windows folder and you are mounting this folder on /media mount point or folder.


Finally you will be able to see you mounted folders using below command:

df -h

Read more ...

EXPDP IMPDP Failed with ORA-39065, ORA-06512, ORA-23603, ORA-39079, ORA-25205


Datapump Import/Export fails with ORA-39065, ORA-39078, ORA-06512, ORA-25205, ORA-24033,ORA-39014



ORA-39065: unexpected master process exception in RECEIVE
ORA-39078: unable to dequeue message for agent MCP from queue "KUPC$C_1_20090220124816"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPC$QUE_INT", line 609
ORA-25205: the QUEUE SYS.KUPC$C_1_20090220124816 does not exist
Job "SYSTEM"."SYS_EXPORT_FULL_01" stopped due to fatal error at 14:21:39
ORA-39014: One or more workers have prematurely exited.
ORA-39029: worker 1 with process name "DW01" prematurely terminated
ORA-31671: Worker process DW01 had an unhandled exception.
ORA-39079: unable to enqueue message DG,KUPC$C_1_20090220124816,KUPC$A_1_20090220124822,MCP,35193,Y
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.KUPC$QUE_INT", line 969
ORA-23603: STREAMS enqueue aborted due to low SGA
ORA-06512: at "SYS.KUPW$WORKER", line 1602
ORA-06512: at line 2



Resolution Steps:
===============

The error message "ORA-23603: STREAMS enqueue aborted due to low SGA" clearly indicates that the streams pool is insufficiently sized.

The Streams Pool size was not sufficiently sized.


Increase the STREAMS_POOL_SIZE parameter or if using Automatic Memory Management (AMM) in 11g, increase the MEMORY_TARGET and MEMORY_MAX_TARGET.
Using AMM, you can also still specify a STREAMS_POOL_SIZE parameter that will be used as a minimum value.


To increase streams pool size:

SQL> show parameter streams

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
streams_pool_size                    big integer 0

SQL> alter system set streams_pool_size=100m scope=both;

System altered.

After increasing strams_pool_size clear all the dump and log file and start the export again.


Done!!!!

Read more ...

Error in Process orapwd.exe and unable to find error file opw.msb

I was trying to install Oracle 11g R2(64bit) on Windows 7 64 bit OS.
But While Creating Database using DBCA i got this error. Below is the screenshot.


Error in Process: %ORACLE_HOME%\server\bin\orapwd.exe
Unable to find error file %ORACLE_HOME%\RDBMS\opw<lang>.msb




Resolution:

Set proper Home and Path using cmd and launch the dbca.


 C:\Users\orahow>set ORACLE_HOME=C:\Oracle\app\oracle\product\11.2.0\dbhome_1
 C:\Users\orahow>set PATH=C:\Oracle\app\oracle\product\11.2.0\dbhome_1\server\bin:$PATH:.
  C:\Users\orahow> dbca

Read more ...

Oracle Listener failed to start with error TNS-12555, TNS-00525, TNS-12560

 As oracle user, when I tried to start the listener using lsnrctl start command, I get the below messages:

[oracle@orahow ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 25-MAR-2017 08:24:46

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Starting /data/oracle/app/product/11.2.0.3/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /data/oracle/app/product/11.2.0.3/dbhome_1/network/admin/listener.ora
Log messages written to /data/oracle/app/product/11.2.0.3/dbhome_1/log/diag/tnslsnr/ip-172-31-21-209/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=171.31.21.209)(PORT=1521)))
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=extproc)))
TNS-12555: TNS:permission denied
TNS-12560: TNS:protocol adapter error
TNS-00525: Insufficient privilege for operation
Linux Error: 1: Operation not permitted

Listener failed to start. See the error message(s) above...

Cause:

In the directory /var/tmp/.oracle there exist some socket files which do not belong to oracle user but to another user (e.g. oraapp) and another group (e.g. root).

Example:

$ ls -l /var/tmp/.oracle
srwxrwxrwx 1 oraapp oraapp 0 Mar  8 12:08 s#1947.2
srwxrwxrwx 1 oraapp oraapp 0 Mar  8 12:08 s#1947.1
srwxrwxrwx 1 oraapp oraapp 0 Mar  8 16:15 s#5200.1
srwxrwxrwx 1 oraapp oraapp 0 Mar  8 16:15 s#5200.2
srwxrwxrwx 1 oraapp oraapp 0 Mar  8 16:54 s#2021.2
srwxrwxrwx 1 oraapp oraapp 0 Mar  8 16:54 s#2021.1
srwxrwxrwx 1 oraapp oraapp 0 Mar  9 08:58 s#3348.2
srwxrwxrwx 1 oraapp oraapp 0 Mar  9 08:58 s#3348.1



When the Listener process starts, it tries to create the following socket files:

/var/tmp/.oracle/s#<pid>.1
/var/tmp/.oracle/s#<pid>.2
/var/tmp/.oracle/sREGISTER

where <pid> is the ID of the operating system process for the Listener.

As the file /var/tmp/.oracle/sREGISTER already exists and belongs to a UNIX user other than oracle, the Listener process cannot create a new socket file with that name. Therefore the Listener fails to start.

Resolution:

Delete all socket files from directory /var/tmp/.oracle as UNIX user root.


Start the Listener by executing the command "lsnrctl start" using oracle user.

[oracle@orahow]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 25-MAR-2017 08:32:43

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Starting /data/oracle/app/product/11.2.0.3/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /data/oracle/app/product/11.2.0.3/dbhome_1/network/admin/listener.ora
Log messages written to /data/oracle/app/product/11.2.0.3/dbhome_1/log/diag/tnslsnr/ip-171-31-21-209/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.31.21.209)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=171.31.21.209)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                25-MAR-2017 08:32:43
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/app/product/11.2.0.3/dbhome_1/network/admin/listener.ora
Listener Log File         /data/oracle/app/product/11.2.0.3/dbhome_1/log/diag/tnslsnr/ip-171-31-21-209/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=171.31.21.209)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Services Summary...
Service "almnew" has 1 instance(s).
  Instance "almnew", status UNKNOWN, has 1 handler(s) for this service...
Service "extproc" has 1 instance(s).
  Instance "extproc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
Read more ...

CONTACT

Name

Email *

Message *