Interview Questions | Oracle DBA Questions | Interview Questions



Get "Oracle DBA Questions" Category

Sort by:

Few Questions on Oracle PL/SQL Programming

The CASE expression uses a selector which is: An expression whose value is used to select one of several alternatives.

With the CASE construct, if none of the legs is selected: Then the case_not_found exception is raised.

Read more on Few Questions on Oracle PL/SQL Programming…

I know the nvl function only allows the same data type(ie. number or char or date Nvl(comm, 0)), if commission is null then the text œNot Applicable want to display, instead of blank space. How do I write the query?

 SQL> select nvl(to_char(comm.),’NA’) from emp;

Output :

NVL(TO_CHAR(COMM),’NA’)
———————–
NA
300
500
NA
1400
NA
NA

How to display the number value in Words?

SQL> select sal, (to_char(to_date(sal,’j’), ‘jsp’))
from emp;
the output like,

      SAL (TO_CHAR(TO_DATE(SAL,’J’),’JSP’))
——— —————————————————–
      800 eight hundred
     1600 one thousand six hundred
     1250 one thousand two hundred fifty
If you want to add some text like,
Rs. Three Thousand only.
SQL> select sal  “Salary “,
 (‘ Rs. ‘|| (to_char(to_date(sal,’j’), ‘Jsp’))|| ‘ only.’))
 ”Sal in Words” from emp
/

Read more on How to display the number value in Words?…

How do I eliminate the duplicate rows ?

SQL> delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name);
or
SQL> delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid)  from table_name tb where ta.dv=tb.dv);

Read more on How do I eliminate the duplicate rows ?…

Which are the different pseudocolumns in Oracle?

A pseudocolumn behaves like a table column, but is not actually stored in the table. You can select from pseudocolumns, but you cannot insert, update, or delete their values.

 

This section describes these pseudocolumns:

Read more on Which are the different pseudocolumns in Oracle?…

What is conventional loading and direct loading?

SQL*Loader can load data into a database using two different paths:

 

Conventional path loads and direct path loads. A conventional path load proceeds through the normal SQL processing layer of Oracle7.

Read more on What is conventional loading and direct loading?…

Can one use dynamic SQL statements from PL/SQL?

Starting from Oracle8i one can use the “EXECUTE IMMEDIATE” statement to execute dynamic SQL and PL/SQL statements (statements created at run-time). Look at these examples. Note that statements are NOT terminated by semicolons:
EXECUTE IMMEDIATE ‘CREATE TABLE x (a NUMBER)’;

Read more on Can one use dynamic SQL statements from PL/SQL?…

Which are the different integrity constraints?

Oracle uses integrity constraints to prevent invalid data entry into the base tables of the database. You can define integrity constraints to enforce the business rules that are associated with the     

Read more on Which are the different integrity constraints?…

What are Implicit and Explicit cursors?

Oracle uses work areas called private SQL areas to create SQL statements.
PL/SQL construct to identify each and every work are used, is called as Cursor.
For SQL queries returning a single row, PL/SQL declares all implicit cursors.
For queries that returning more than one row, the cursor needs to be explicitly declared.

Read more on What are Implicit and Explicit cursors?…

How to display odd or even number of records?

 Odd number of records:
select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
1
3
5

Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
2
4
6

Read more on How to display odd or even number of records?…

Display the records between two range

select rownum, empno, ename  from emp  where  rowid in  

(select rowid from emp where rownum <=&upto  minus  select rowid from emp where rownum<&Start);

Enter value for upto: 10
Enter value for Start: 7

Read more on Display the records between two range…