Monday, January 13, 2014

/*+ APPEND */ hint in serial & parallel mode in oracle.

/*+ APPEND */ hint enables the optimizer to use direct-path insert particularly in insert statements in oracle

In serial mode, direct path can be used only if you include the APPEND hint.
Conventional insert is the default in serial mode. 
It means that NO UNDO will be written. 
UNDO is backed by REDO, so the REDO volume will be accordingly reduced.

Direct path insert is the default in parallel mode. 
In parallel mode, conventional insert can be used only if you specify the /*+ NOAPPEND */ hint.
data is appended to the end of the table,rather than using existing space currently allocated to the table, means after HWM of the current block. 

Direct-path inserts are considerably faster than conventional inserts.

Sunday, December 8, 2013

What are the Bind Variables & Substitution Variables?

Bind Variables are also called host variables, which is accessed even after the PL/SQL block is executed.
It can be create using VARIABLE keyword and referenced with a preceding colon-:.

ex.
VARIABLE sal number;
begin
select salary into :sal from emp where emp_id = 11;
end;
/
select firstname , lastname from emp where salary = :sal;

Substitution Variables are used to get user input at run time to avoid hard-coding of values that we can provide run time also.
We can reference the same with in PL/SQL block with symbol ampersand-&.

VARIABLE sal number;
accept empid prompt 'provide emp id' 
declare
v_empid number := &empid; 
begin
select salary into :sal from emp where emp_id = v_empid;
end;
/
select firstname , lastname from emp where salary = :sal;


Tuesday, October 9, 2012

New PL/SQL Features and Enhancements in Oracle 11g


The new PL/SQL features and enhancements in Oracle 11g are as follows:
  • Enhancements to regular expression built-in SQL functions
  • SIMPLE_INTEGER, SIMPLE_FLOAT, and SIMPLE_DOUBLE datatypes
  • CONTINUE statement
  • Sequences in PL/SQL expressions
  • Dynamic SQL enhancements
  • More control over triggers
  • Compound triggers
  • Database resident connection pool
  • Automatic subprogram inlining
  • PL/Scope
  • PL/SQL hierarchical profiler
  • PL/SQL native compiler generates native code directly

Saturday, September 3, 2011

What are the major difference between Oracle9i and Oracle10g?

Oracle 9i has the following new features: 

  1. Direct XML database support.
  2. Oracle Data Guard and enhancements.
  3. New data sharing and replication features.
  4. Compresses keys in tables when loading data.
  5. Security Improvements.
  6. Manage system table spaces locally.
  7. Automated DBA.
Oracle 10g has following new features:
  1. New drop database and alter database begin backup syntax.
  2. Oracle 10g Data Guard Broker and RAC to support Redo Log Transport.
  3. SQL apply feature and regular expression support.
  4. Supports HTML database.
  5. Recycle bin for storing objects and new purge command.
  6. SYSAUX table space and rename table space command.
  7. Automated Storage Management (ASM).
  8. Automatic Workload Repository (AWR).
  9. Automatic Database Diagnostic Monitor (ADDM)
  10. PLS_INTEGER, a new data type was added which enhances performance. ANYDATA data type was introduced to hold a data of variant feature.

Tuesday, June 28, 2011

How to get list of Top Performing SQLs in Oracle?

The V$SQLAREA is used for identifying the top most resource-consuming SQL statements with a variety of criteria. It is widely useful to Database Administrators, Application Developers, Oracle Support Engineers and generally anyone involved in an Oracle Database Performance Tuning activity.
The thresholds used are the same as used by default in Statspack:
Buffer Gets : 10,000
Physical Reads : 1,000
Executions : 100
Parse Calls : 1,000
Sharable Memory : 1,048576
Version Count : 20
For Top Buffer Gets >>>
SELECT * FROM(
SELECT substr(sql_text,1,40) sql,
buffer_gets, executions, buffer_gets/executions "Gets/Exec",hash_value,address
FROM V$SQLAREA
WHERE buffer_gets > 10000
ORDER BY buffer_gets DESC
)WHERE rownum <= 10;
For Top Physical Reads >>>
SELECT * FROM
(SELECT substr(sql_text,1,40) sql,
disk_reads, executions, disk_reads/executions "Reads/Exec",
hash_value,address
FROM V$SQLAREA
WHERE disk_reads > 1000
ORDER BY disk_reads DESC)
WHERE rownum <= 10;
For Top Executions >>>
SELECT * FROM
(SELECT substr(sql_text,1,40) sql,
executions, rows_processed, rows_processed/executions "Rows/Exec",
hash_value,address
FROM V$SQLAREA
WHERE executions > 100
ORDER BY executions DESC)
WHERE rownum <= 10;
For Top Parse Calls >>>
SELECT * FROM
(SELECT substr(sql_text,1,40) sql,
parse_calls, executions, hash_value,address
FROM V$SQLAREA
WHERE parse_calls > 1000
ORDER BY parse_calls DESC)
WHERE rownum <= 10;

What are the Collections or Composite Datatypes in PL/SQL?

A Composite Datatypes are internal components that can be manipulated individually in PL/SQL are also called as PL/SQL Collections.

A PL/SQL collection is an ordered group of elements of the same type. It is a general concept that encompasses lists, arrays, and other familiar data types. Each element has a unique subscript that determines its position in the collection.

Three types of PL/SQL collections are in Oracle.

Index-by tables :

It is also known as associative arrays, let you look up elements using arbitrary numbers and strings for subscript values. They are similar to hash tables in other programming languages.Index-by tables is a non -persistent collection and it can’t store in the database.

Nested tables:

It can hold an arbitrary number of elements. They use sequential numbers as subscripts. You can define equivalent SQL types, allowing nested tables to be stored in database tables and manipulated through SQL.

Varrays :

Variable-Size Arrays (Varrays) can hold a fixed number of elements (although you can change the number of elements at runtime). They use sequential numbers as subscripts. You can define equivalent SQL types, allowing varrays to be stored in database tables. They can be stored and retrieved through SQL, but with less flexibility than nested tables.

Nested tables and Varrays are persistent collections and it is stored in database.

Tuesday, March 15, 2011

What are the process states in Unix?

As a process executes it changes state according to its circumstances. Unix processes have the following states:

Running : The process is either running or it is ready to run .

Waiting  : The process is waiting for an event or for a resource.

Stopped : The process has been stopped, usually by receiving a signal.

Zombie   : The process is dead but have not been removed from the process table.

When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it - for example, the parent may need to check the child's exit status.

To be able to get this information, the parent calls wait() In the interval between the child terminating and the parent calling wait() , the child is said to be a “zombie” state.
while using ps command, the child will have status  Z for Zombie.