Skip to main content

Posts

CLOB Argument In EXECUTE IMMEDIATE

Oracle EXECUTE IMMEDIATE statement implements Dynamic SQL in Oracle. Before Oracle 11g, EXECUTE IMMEDIATE supported SQL string statements. Oracle 11g allows the usage of CLOB datatypes as an argument which eradicates the constraint we faced on the length of strings when passed as an argument to Execute immediate. But a PLSQL block written on Oracle 11g with  C LOB datatypes as an argument to  EXECUTE IMMEDIATE  will not be executed on Oracle 10g.

Oracle 11g export using EXP utility missing some tables

Problem:- I have recently exported a 11g schema using 11g EXP utility and tried to import into another 11g Instance using 11g IMP utility. But, not all the tables got transferred to the destination instance. On further debugging, I found out that empty tables i.e. tables with NO ROWS (0 rows) did not get exported to dump thus they were missing. Cause:- This is due to oracle feature "Segment creation on Demand (Deferred Segment Creation). Solution :- 1) Use the new Oracle Data Pump utilities for the export and import:  expdp/ impdp instead of exp/imp 2) Turn off the Oracle feature before creating any object     ALTER SYSTEM SET DEFERRED_SEGMENT_CREATION=FALSE; 3) Force the allocation of extents on each empty table using the following command     ALTER TABLE <table_name> ALLOCATE EXTENT;     Re-run the export EXP command, which would export the empty tables as well.

Get Data in Rows and aggregates into columns

The new  PIVOT  operator   in 11g  takes data in separate rows, aggregates it and converts it into columns:- For example we have data in such a format:-  SQL> Select * from (.....) Name Time_Diff Pivot_For A 0 0:0:0.0 First A 0 0:0:2.428 Second A 0 0:0:5.548 Third A 0 0:1:1.991 Fourth B 0 0:2:0.0 First B 0 0:0:3.428 Second B 0 0:0:5.248 Third B 0 0:2:3.991 Fourth C 0 1:2:0.0 First C 0 2:0:3.428 Second C 0 3:0:5.248 Third C 0 0:45:3.991 Fourth To aggregate Data in columns we can use Pivot operator in Oracle as follows:- SQL> Select * from (.....) PIVOT(           Max(Time_Diff)           FOR  Pivot_For in ('First' as First, 'Second' as Second,           'Third' as Third, 'Fourth' as Fourth)         ) N ame First Second Third Fourth A 0 0:0:0.0 0 0:0:

ORA-12520: TNS:listener could not find available handler for requested type of server

Cause:- The most frequent cause is the smaller value of the parameter "PROCESSES" set in Oracle, which needs to be increased in order to solve this issue PROCESSES  specifies the maximum number of operating system user processes that can simultaneously connect to Oracle Value of this parameter can be fetched using query:- SQL> show parameter process SQL>SELECT name, value  FROM gv$parameter  WHERE isdefault = 'FALSE';  Solution:- Login as a system DBA ( conn  sys  as sysdba ) SQL>  alter system set processes=200 scope=spfile Restart the oracle database and the newly entered value for processes parameter will come into effect.

ORA-28001: the password has expired

Crosscheck by value of accout_status field in dba_users view. sql> select username,account_status from dba_users; Execute the following query Sql > select * from dba_profiles; the output of this query will show, Default Password expire lifetime  PASSWORD_LIFE_TIME field is responsible for expiring of password after x days. execute following command to disable this feature: Sql> ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED; Now crosscheck for disabling of this feature. Sql > select * from dba_profiles; Now change the password of locked user and unlock using following. sql> alter user [user_name] identified by [password]; sql> alter user [User_name] account unlock; Crosscheck by value of accout_status field in dba_users view. sql> select username,account_status from dba_users; The value of account_status filed should by " OPEN " for corresponding user.