Friday, October 11, 2013

SQL and PL/SQL Interview Questions- Part 2 - New question set 2013

SQL and PL/SQL Interview Questions- Part 2

Q.Explain the usage of WHERE CURRENT OF clause in cursors ?
WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor. Database Triggers

Q.In a Distributed Database System Can we execute two queries simultaneously ? Justify ?
When 2 people are using DRL command it is possible to execute multiple queries simultaneously.
When we are performing DML operation (update,delete) exclusive lock will be applied on specific record so, DML operation is not possible.
As Distributed database system based on 2 phase commit,one query is independent of 2 nd query so of course we can run.

Q.Can Commit,Rollback ,Savepoint be used in Database Triggers?If yes than HOW? If no Why?With Reasons

we cannot commit inside a trigger.
As we all know that when a dml is complete one can issue a commit.
A trigger if created is fired before the dml completes.
so we cannot commit intermediately.

Q.What will the Output for this Coding?
Declare
Cursor c1 is select * from emp FORUPDATE;
Z c1%rowtype;
Begin
Open C1;
Fetch c1 into Z;
Commit;
Fetch c1 in to Z;
end;
By declaring this cursor we can update the table emp through z,means wo not need to write table name for updation,it may be only by "z".

Q.How we can create a table through procedure ?

You can create table from procedure using Execute immediate command.

Q.What are two parts of package ?

package has two parts
1.Package specification
2.Package body
In the specification,where we declare variable,function,procedure
that is global to the package and local to the schema.
package body contains the defination of the function,procedure.we can also declare private function and procedure which is not accessble
out side the package.
The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY. Package Specification contains declarations that are global to the packages and local to the schema.
Package Body contains actual procedures and local declaration of the procedures and cursor declarations.

Q.The most important DDL statements in SQL are?
CREATE TABLE - creates a new database table
ALTER TABLE - alters (changes) a database table
DROP TABLE - deletes a database table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index

Q.What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?

A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.

Q.What is the basic structure of PL/SQL ?
PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.

Q.What is Correlated Subquery?
Correlated Subquery is a subquery that is evaluated once for each row processed by the parent statement. Parent statement can be Select, Update or Delete. Use CRSQ to answer multipart questions whose answer depends on the value in each row processed by parent statement.

Q.Write the order of precedence for validation of a column in a table ?

I. done using Database triggers.
ii. done using Integarity Constraints.
I & ii.
Exception
First column should be validated by constraints and then Triggers

Q.What are two virtual tables available during database trigger execution ?

The table columns are referred as OLD.column_name and NEW.column_name.
For triggers related to INSERT only NEW.column_name values only available.
For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
For triggers related to DELETE only OLD.column_name values only available.
Two tables are: OLD and NEW.
Insert Trigger :
OLD - no value.
NEW - inserted value.
UPDATE TRIGGER -
OLD- old value.
NEW- new updated value.
DELETE TRIGGER -
OLD - old value.
NEW - no value.

Q.The SELECT INTO Statement is most often used to create backup copies of tables or for archiving records?
SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source
SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source WHERE column_name operator value.

Q.What is Data types?
Max. columns in a table is 255. Max. Char size is 255, Long is 64K & Number is 38 digits.
Cannot Query on a long column.
Char, Varchar2 Max. size is 2000 & default is 1 byte.
Number(p,s) p is precision range 1 to 38, s is scale -84 to 127.
Long Character data of variable length upto 2GB.
Date Range from Jan 4712 BC to Dec 4712 AD.
Raw Stores Binary data (Graphics Image & Digitized Sound). Max. is 255 bytes.
Mslabel Binary format of an OS label. Used primarily with Trusted Oracle.

Q.What is Pragma EXECPTION_INIT? Explain the usage?

The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)

Q.What is a cursor ? Why Cursor is required ?
The oracle server uses works areas
called private sql area.Here all the DML statement is executed and to processing statement.basically
it's a implicit cursor.
there are two types of cursor
1.Implicit cursor.
2.Explicit cursor.
Implicit cursor is open for all DML statement.after execute the statement cursor is atomatically closed.
Explicit cursor is created by programmer.
explicit cursor is needed when
query returns more than one rows.
In that case,programmer creates
explicit cursor.open the cursor.
then fetch the value from the active set.
after fetching all the value,
cursor is closed by programmer.

Q.Explain the usage of WHERE CURRENT OF clause in cursors?
WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor. Database Triggers

Q.What is the basic structure of PL/SQL?
PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.

Q.Who to put a unique constraint on column if duplicate data is already present in that column?
If duplicate data is already there then instead of putting unique constraint on one column, put unique constraint on two or more columns.

Q.What is SET?
SET command changes the system variables affecting the report environment.

Q.What is Locking?
Locking are mechanisms intended to prevent destructive interaction between users accessing data. Locks are used to achieve.

Q.Explain the usage of WHERE CURRENT OF clause in cursors?
WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor. Database Triggers

Q.The INSERT INTO Statements in SQL?
INSERT INTO table_name VALUES (value1, value2,....)
INSERT INTO table_name (column1, column2,...) VALUES (value1, value2,....)

Q.What is the basic structure of PL/SQL?
PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.

Q.What is difference between a Cursor declared in a procedure and Cursor declared in a package specification?
A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.

Q.I can not see the answer of the pl/cql code like addition of two no.s. afterall i write dbms_output.put_line('addition is'|| c). Only the line 'PL/SQL procedure successfully completed.' is showing when i end the code by /
before executing the procedure,
set serveroutput on;

Q.Where the Pre_defined_exceptions are stored?
In the standard package.
Procedures, Functions & Packages ;

Q.What is difference between a PROCEDURE & FUNCTION?
A FUNCTION is always returns a value using the return statement.
A PROCEDURE may return one or more values through parameters or may not return at all.

Q.How can a function retun more than one value in oracle with proper example?
yes we can use objects, arrays to return more than one value

Q.How to know the last executed procedure?
Execute procedure name (parameter1,parameter2)
Select timestamps, owner, obj_name, action_name from dba_audit_trail;this statement gives last executed time for procedure , function & package.

Q.Name the tables where characteristics of Package, procedure and functions are stored ?
User_objects, User_Source and User_error.

Q.1)What is the starting "oracle error number"?
2)What is meant by forward declaration in functions?
One must declare an identifier before referencing it. Once it is declared it can be referred even before defining it in the PL/SQL. This rule applies to function and procedures also

Q.What is difference between a PROCEDURE & FUNCTION ?
A FUNCTION is always returns a value using the return statement.
A PROCEDURE may return one or more values through parameters or may not return at all.
In case of function,it must have
return type.
In case of procedure,it may or may n't have return type.
In case of function, only it takes IN parameters
IN case of procedure
only it take IN,OUT,INOUT parameters..

Q.Give the structure of the function ?
FUNCTION name (argument list .....) Return datatype is
local variable declarations
Begin
executable statements
Exception
execution handlers
End;

Q.What is Union?
Union is the product of two or more tables. Which is removed duplicate values from the query.
Union is the product of two or more tables.

Q.What are the components of a PL/SQL Block ?
Declare
variable declaration
Begin
Execution part
Exception
Exception handling
End;
Declarative part, Executable part and Exception part.
Datatypes PL/SQL

Q.What are two virtual tables available during database trigger execution?
The table columns are referred as OLD.column_name and NEW.column_name.
For triggers related to INSERT only NEW.column_name values only available.
For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
For triggers related to DELETE only OLD.column_name values only available.

Q.What is Synonyms?
Synonyms is the alias name for table, views, sequences & procedures and are created for reasons of Security and Convenience.
Two levels are Public - created by DBA & accessible to all the users. Private - Accessible to creator only. Advantages are referencing without specifying the owner and Flexibility to customize a more meaningful naming convention.

Q.What is COMPUTE?
command control computations on subsets created by the BREAK command.When we are trying to determine the sum of some columns in a result set we can use Compute. This function is used for reporting purpose.

Q.What is the use of CASCADE CONSTRAINTS?
Integrity key is violated when one tried to delete parent key value when foreign key value.
A parent key value can only be deleted after foreign key value.
Cascade constraints has dual purpose.
1.Alter table command can be issued with "ON DELETE CASCADE"
When this is done one can run delete command with cascade constriaint to delete parent key value.
2.To drop a table that has parent values.
With cascade constraint,foreign key constraint on child table and parent table is dropped.The child table still exits.
When this clause is used with the DROP command, a parent table can be dropped even when a child table exists.

Q.The Update Statement in SQL.
UPDATE table_name SET column_name = new_value WHERE column_name = some_value

Q.How Can i convert the Columns In to Row in a oracle Select Query ?
By using matrix report query
Example:
select job,sum(DECODE(deptno,10,sal)) "d10_sal",
sum(DECODE(deptno,20,sal)) "d20_sal",
sum(DECODE(deptno,30,sall)) "d30_sal",
sum(sal) "total"
from emp group by job;

Q.What are two virtual tables available during database trigger execution?
The table columns are referred as OLD.column_name and NEW.column_name.
For triggers related to INSERT only NEW.column_name values only available.
For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
For triggers related to DELETE only OLD.column_name values only available.

Q.What is difference between % ROWTYPE and TYPE RECORD?
% ROWTYPE is to be used whenever query returns a entire row of a table or view.
TYPE rec RECORD is to be used whenever query returns columns of different
table or views and variables.
E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type);
e_rec emp% ROWTYPE
cursor c1 is select empno,deptno from emp;
e_rec c1 %ROWTYPE.
One more point : When we have a variable of typer RECORD we have declare additional variables but with %rowtype, we can only have the fields that are present in the table

Q.How can a function retun more than one value in oracle with proper example?
yes we can use objects, arrays to return more than one value

Q.Write a PL/SQL block to list all the managers
DECLARE
LV_MANAGER_NAME VARCHAR2(100);
LN_COUNT NUMBER;
CURSOR C1 AS
SELECT * FROM EMP_DETAILS WHERE DESIGNATION = 'MANAGER'
BEGIN
LN_COUNT := 0;
FOR EMPDET IN C1 LOOP
LV_MANAGER_NAME := EMPDET.EMP_NAME;
LN_COUNT = LN_COUNT+1;
DBMS_OUTPUT.PUT_LINE('MANAGER '||LN_COUNT||' -> '||LV_MANAGER_NAME);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('EXCEPTION OCCURED:'||SQLERRM);
END;

Q.Explian rowid,rownum?What are the pseduocolumns we have?
ROWID - Hexa decimal number each and every row having unique.Used in searching
ROWNUM - It is a integer number also unique for sorting Normally TOP N Analysys.
Other Psudo Column are
NEXTVAL,CURRVAL Of sequence are some examples

Q.What is Pragma EXECPTION_INIT ? Explain the usage ?
The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)

Q.Write a PL/SQL block to update the salary of an employee whose empno is 7839 and print the message as ?Record Updated?.
begin
update employee(tablename) set salary=(salary)*o.1 where empno=7839;
dbms_output.put_line('record updated');
end;
declare
a exception;
begin
update emp set sal=(sal*0.1) where empno=7839;
if sql%rowcount>0 then
dbms_output.put_line(sql%rowcount ||' records are updated' );
else
raise a;
end if;
exception
when a then
dbms_output.put_line('records are not updated');
end;

Q.How packaged procedures and functions are called from the following?
a.Stored procedure or anonymous block
b.an application program such a PRC *C, PRO* COBOL
c.SQL *PLUS
a.PACKAGE NAME.PROCEDURE NAME (parameters);
variable := PACKAGE NAME.FUNCTION NAME (arguments);
EXEC SQL EXECUTE
b.BEGIN
PACKAGE NAME.PROCEDURE NAME (parameters)
variable := PACKAGE NAME.FUNCTION NAME (arguments);
END;
END EXEC;
c.EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any out/in-out parameters. A function can not be called.

Q.What is TTITLE and BTITLE?
TTITLE & BTITLE are commands to control report headings & footers.

Q.Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ? Why
It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.
No, we can not use Commit or Rollback, within a trigger. To understand, take one simple example...
Suppose two persons are using one common table and they both have written trigger on that table. If in the first trigger we are using commit/rollback, then the second use would get some unwanted result.
That is the reason, why we don't use Commit/Rollback in Triggers.
Yeah. If some type of failure/ breakdown occurs, in that case Oracle automatically Rollback the data.

Q.select seq1.nextval from dual
It returns two values at a time.
100
100
Is it possible?If so how?
select naw1.nextval,naw1.currval into n from dual;
Well, in a way it is:
SQL> create sequence foo_seq start with 100 increment by 3;
Sequence created.
SQL> create table dual (dummy varchar2(1));
Table created.
SQL> insert into dual values ('X');
1 row created.
SQL> insert into dual values ('Y');
1 row created.
SQL> commit;
Commit complete.
SQL> select foo_seq.nextval from dual;
NEXTVAL
----------
100
103
SQL>
It's a mean trick to play on developers.

Q.What will the Output for this Coding>
Declare
Cursor c1 is select * from emp FORUPDATE;
Z c1%rowtype;
Begin
Open C1;
Fetch c1 into Z;
Commit;
Fetch c1 in to Z;
end;
By declaring this cursor we can update the table emp through z,means wo not need to write table name for updation,it may be only by "z".
By issuing the TCL like commit or rollback, the cursor will be closed automatically, you cannot fetch again.


Q.How to avoid using cursors? What to use instead of cursor and in what cases to do so?
Just use subquery in for clause
ex:For emprec in (select * from emp)
loop
dbms_output.put_line(emprec.empno);
end loop;
no exit statement needed
implicit open,fetch,close occurs

Q.What are the return values of functions SQLCODE and SQLERRM?
SQLCODE returns the latest code of the error that has occurred.
SQLERRM returns the relevant error message of the SQLCODE.

Q.Explian rowid, rownum?what are the psoducolumns we have?
ROWID - Hexa decimal number each and every row having unique.Used in searching.
ROWNUM - It is a integer number also unique for sorting Normally TOP N Analysys.
Other Psudo Column are
NEXTVAL,CURRVAL Of sequence are some exampls
psudo columns are default columns provided by oracle

Q.Give the Types of modules in a form?
Form
Menu
Library

Q.What happens if a procedure that updates a column of table X is called in a database trigger of the same table?
Mutation of table occurs.

Q.Can we declare a column having number data type and its scale is larger than pricesion
ex: column_name NUMBER(10,100),
column_name NUMBAER(10,-84)
Yes,we can declare a column with above condition.table created successfully.
yes, 100 is the total size and 10 is included in 100

Q.What is SQL Integrity?
Assures database data and structures reflects all changes made to them in the correct sequence. Locks ensure data integrity and maximum concurrent access to data. Commit statement releases all locks. Types of locks are given below.
Data Locks protects data i.e. Table or Row lock.
Dictionary Locks protects the structure of database object i.e. ensures table's structure does not change for the duration of the transaction.
Internal Locks & Latches protects the internal database structures. They are automatic.
Exclusive Lock allows queries on locked table but no other activity is allowed.
Share Lock allows concurrent queries but prohibits updates to the locked tables.
Row Share allows concurrent access to the locked table but prohibits for a exclusive table lock.
Row Exclusive same as Row Share but prohibits locking in shared mode.
Shared Row Exclusive locks the whole table and allows users to look at rows in the table but prohibit others from locking the table in share or updating them.
Share Update are synonymous with Row Share.

Q.What are the components of a PL/SQL block ?
components of PL/SQL are:
declare:
(optional) variable declare
Begin:
(Mandatory)Procedural statement
Exception:
(optional)
error to be trapped
End:
(Mandatory)
So BEGIN and END are required in PL/SQL block

Q.What is difference between % ROWTYPE and TYPE RECORD ?
% ROWTYPE is to be used whenever query returns a entire row of a table or view.
TYPE rec RECORD is to be used whenever query returns columns of different table or views and variables.
E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type);
e_rec emp% ROWTYPE
cursor c1 is select empno,deptno from emp;
e_rec c1 %ROWTYPE.

Q.What are the datatypes a available in PL/SQL ?
1.Character Datatypes:
char(size), nchar(size), varchar2(size), nvarchar2(size),long, raw, longraw
2.Numeric Datatypes number(p,s), numeric(p,s),float, dec(p,s), decimal(p,s),integer, int, smallint,real, double precision
3.Date/Time Datatypes:
date, timestamp, timestamp with local time zone, timestamp with time zone, interval year to month, interval day to second
4.LOB data types:
bfile,blob,clob,nclob
5. Rowid Data types:
rowid,urowid
Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN. Some composite data types such as RECORD & TABLE.

Q.Explian rowid, rownum? what are the psoducolumns we have ?
ROWID - Hexa decimal number each and every row having unique.Used in searching.
ROWNUM - It is a integer number also unique for sorting Normally TOP N Analysys.
Other Psudo Column are NEXTVAL,CURRVAL Of sequence are some examples
psudo columns are default columns provided by oracle
both rowid n rownum are psedocolumns, but
rowid- is physical address for each record in the memory.
rownum gives the numbering to rows returned by sql select statement.

Q.What is Indexes?
Indexes are optional structures associated with tables used to speed query execution and/or guarantee uniqueness. Create an index if there are frequent retrieval of fewer than 10-15% of the rows in a large table and columns are referenced frequently in the WHERE clause. Implied tradeoff is query speed vs. update speed. Oracle automatically update indexes. Concatenated index max. is 16 columns.

Q.What is Raise_application_error?
Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.

Q.State the difference between implict and explict cursors?

Collapse/Expand Answer of Question State the difference between implict and explict cursors?
Implicit Cursor are declared and used by the oracle internally. whereas the explicit cursors are declared and used by the user. more over implicitly cursors are no need to declare oracle creates and process and closes autometically. the explicit cursor should be declared and closed by the user.
Implicit cursors are used for single row query whereas explicit cursor is used for multiple row query
Do you have any collection of Interview Questions and interested to share with us!!
Please send that collection to iq@GlobalGuideline.Com along with the category and sub category information

Q.What are the modes of parameters that can be passed to a procedure?
IN,OUT,IN-OUT parameters.

Q.What will happen after commit statement?
Cursor C1 is
Select empno,
ename from emp;
Begin
open C1; loop
Fetch C1 into
eno.ename;
Exit When
C1 %notfound;-----
commit;
end loop;
end;
The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.

Q.How many types of database triggers can be specified on a table? What are they?
Insert Update Delete
Before Row o.k. o.k. o.k.
After Row o.k. o.k. o.k.
Before Statement o.k. o.k. o.k.
After Statement o.k. o.k. o.k.
If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.
If WHEN clause is specified, the trigger fires according to the returned Boolean value.

Q.What will be the Output for this Coding

Declare
Cursor c1 is select * from emp FORUPDATE;
Z c1%rowtype;
Begin
Open C1;
Fetch c1 into Z;
Commit;
Fetch c1 in to Z;
By declaring this cursor we can update the table emp through z,means wo not need to write table name for updation,it may be only by "z".
By issuing the TCL like commit or rollback, the cursor will be closed automatically, you cannat fetch again.

Q.What will happen after commit statement?

Cursor C1 is
Select empno,
ename from emp;
Begin
open C1; loop
Fetch C1 into
eno.ename;
Exit When
C1 %notfound;-----
commit;
end loop;
end;
The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.

Q.What is an oracle stored procedure?


A stored procedure is a sequence of statements that perform specific function.

Q.Explain the usage of WHERE CURRENT OF clause in cursors?

WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor. Database Triggers

SQL and PL SQL Interview Questions - New Question Set 2013

Q.What is a stored procedure ?

A stored procedure is a sequence of statements that perform specific function.
A stored procedure is a named pl/sql block which performs an action.It is stored in the database as a schema object and can be repeatedly executed.It can be invoked, parameterised and nested.

Q.What is SQL*Loader?

SQL*Loader is a product for moving data in external files into tables in an Oracle database. To load data from external files into an Oracle database, two types of input must be provided to SQL*Loader : the data itself and the control file. The control file describes the data to be loaded. It describes the Names and format of the data files, Specifications for loading data and the Data to be loaded (optional). Invoking the loader sqlload username/password controlfilename <options>.

Q.What are the two parts of a procedure ?

the above person have answerd wrong. Or rather the question may be wrong. It should be packages instead of procedures. What are the 2 parts of package ? But the question is what are the 2 parts for procedue!!!
Procedure Specification and Procedure Body.

Q.What is Date Functions?
Date Functions are ADD_MONTHS, LAST_DAY, NEXT_DAY, MONTHS_BETWEEN & SYSDATE.

Q.What is NVL?
NVL: Null value function converts a null value to a non-null value for the purpose of evaluating an expression. Numeric Functions accept numeric I/P & return numeric values. They are MOD, SQRT, ROUND, TRUNC & POWER.

Q.What is Intersect?
Intersect is the product of two tables listing only the matching rows.

Q.How to know the last executed procedure?
Execute procedure name (parameter1,parameter2)
Select timestamps, owner, obj_name, action_name from dba_audit_trail;this statement gives last executed time for procedure , function & package.

Q.What are the Restrictions on Cursor Variables?
Currently, cursor variables are subject to the following restrictions:You cannot declare cursor variables in a package spec. For example, the following declaration is not allowed:CREATE PACKAGE emp_stuff AS TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE; emp_cv EmpCurTyp; -- not allowedEND emp_stuff;You cannot pass cursor variables to a procedure that is called through a database link.If you pass a host cursor variable to PL/SQL, you cannot fetch from it on the server side unless you also open it there on the same server call.You cannot use comparison operators to test cursor variables for equality, inequality, or nullity.You cannot assign nulls to a cursor variable.Database columns cannot store the values of cursor variables. There is no equivalent type to use in a CREATE TABLE statement.You cannot store cursor variables in an associative array, nested table, or varray.Cursors and cursor variables are not interoperable; that is, you cannot use one where the other is expected. For example, you cannot
reference a cursor variable in a cursor FOR loop

Q.What is Minus?
Minus is the product of two tables listing only the non-matching rows.

Q.What are the cursor attributes used in PL/SQL?
% ISOPEN - To check whether cursor is open or not
% ROWCOUNT - Number of rows fetched/updated/deleted.
% FOUND - To check whether cursor has fetched any row. True if rows are fetched.
% NOT FOUND - To check whether cursor has fetched any row. True if no rows are featched.
These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.

Q.What is Consistency?
consistency: states that until commit the data will not be reflected to other users,in order to maintain proper consistency.
consider a example: if user A transfer money to user B. The changes are updates in A account (debit) but until it will be updated in B (credit) too till then others will not be able to see the debit of A. when debit to A and credit to B happen then one can see the updates hence maintain consistency

Q.What are % TYPE and % ROWTYPE? What are the advantages of using these over data types?
% TYPE provides the data type of a variable or a database column to that variable.
% ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
The advantages are : I. Need not know about variable's data type
ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.

Q.What will the Output for this Coding
Declare
Cursor c1 is select * from emp FORUPDATE;
Z c1%rowtype;
Begin
Open C1;
Fetch c1 into Z;
Commit;
Fetch c1 in to Z;
end;
By declaring this cursor we can update the table emp through z,means wo not need to write table name for updation,it may be only by "z".
By issuing the TCL like commit or rollback, the cursor will be closed automatically, you cannat fetch again. You will get an error if you

Q.What is Commit?
Commit is an event that attempts to make data in the database identical to the data in the form. It involves writing or posting data to the database and committing data to the database. Forms check the validity of the data in fields and records during a commit. Validity check are uniqueness, consistency and db restrictions.

Q.Give the structure of the function?
FUNCTION name (argument list .....) Return datatype is
local variable declarations
Begin
executable statements
Exception
execution handlers
End;

Q.What is a cursor ? Why Cursor is required?
Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.

Q.If the application is running very slow? At what points you need to go about the database in order to improve the performance?
For improving performance, we need to check the sql statement blocks , because for every sql satement execution transfor to sql engine and come back to plsq engine that process takes more time to process the plsql block.

Q.What are advantages fo Stored Procedures?
Extensibility,Modularity, Reusability, Maintainability and one time compilation.

Q.What is difference b/w stored procedures and application procedures, stored function and application function?
Stored procedures are subprogrammes stored in the database and can be called &executee multiple times wherein an application procedure is the one being used for a particular application same is the way for function.
Both can be executed any number of times. Only difference is that stored procedures/ functions are stored in database in complied format while the application procedures/functions are not in precomplied format and at run time has to be compiled.

Q.What is a cursor ? Why Cursor is required?
Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.

Q.State the difference between implicit and explicit cursor's.
Implicit Cursor are declared and used by the oracle internally. whereas the explicit cursors are declared and used by the user. more over implicitly cursors are no need to declare oracle creates and process and closes autometically. the explicit cursor should be declared and closed by the user.

Q.How to avoid using cursors? What to use instead of cursor and in what cases to do so?
just use subquery in for clause
ex:
for emprec in (select * from emp)
loop
dbms_output.put_line(emprec.empno);
end loop;
no exit statement needed
implicit open,fetch,close occurs

Q.What is pl/sql?what are the advantages of pl/sql?
PL/SQL(a product of Oracle) is the 'programming language' extension of sql.
It is a full-fledged language although it is specially designed for database centric activities.

Q.How to disable multiple triggers of a table at at a time?
ALTER TABLE<TABLE NAME> DISABLE ALL TRIGGER

Q.How many types of database triggers can be specified on a table ? What are they ?
Insert Update Delete
Before Row o.k. o.k. o.k.
After Row o.k. o.k. o.k.
Before Statement o.k. o.k. o.k.
After Statement o.k. o.k. o.k.
If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.
If WHEN clause is specified, the trigger fires according to the returned Boolean value.

Q.Explain how procedures and functions are called in a PL/SQL block ?
Function can be called from SQL query + explicitly as well
e.g 1)select empno,salary,fn_comm(salary)from employee;
2)commision=fn_comm(salary);
Procedure can be called from begin-end clause.
e.g.
Begin
(
proc_comm(salary);
)
end
Function is called as part of an expression.
sal := calculate_sal ('a822');
procedure is called as a PL/SQL statement
calculate_bonus ('A822');

Q.What will happen after commit statement ?
Cursor C1 is
Select empno,
ename from emp;
Begin
open C1; loop
Fetch C1 into
eno.ename;
Exit When
C1 %notfound;-----
commit;
end loop;
end;
The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.

Q.What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
Trigger will be called... Based on the event what trigger as to do. if trigger is also doing the same update statment then Mutating Table occurs. if trigger is not doing any DML statment nothing happens just Trigger will be called..

Q.Can we declare a column having number data type and its scale is larger than pricesion
ex: column_name NUMBER(10,100),
column_name NUMBAER(10,-84)
Yes,
we can declare a column with above condition.
table created successfully.

Q.The IN operator may be used if you know the exact value you want to return for at least one of the columns.
SELECT column_name FROM table_name WHERE column_name IN (value1,value2,..)

Q.What is SQL Deadlock?
Deadlock is a unique situation in a multi user system that causes two or more users to wait indefinitely for a locked resource. First user needs a resource locked by the second user and the second user needs a resource locked by the first user. To avoid dead locks, avoid using exclusive table lock and if using, use it in the same sequence and use Commit frequently to release locks.

Q.Where the Pre_defined_exceptions are stored ?
In the standard package.
Procedures, Functions & Packages ;

Q. Below is the table
city gender name
delhi male a
delhi female b
mumbai male c
mumbai female d
delhi male e
I want the o/p as follows:
male female
delhi 2 1
mumbai 1 1
Please help me in writing the query that can yield the o/p mentioned above?
select city, sum(decode(gender,'male',1,0)) Male_cnt, sum(gender,'female',1,0) female_cnt
from table_name
group by city
select a.city,a.male,b.female from
(select city,count(gender) male from city where gender='m'group by city,gender)a
join
(select city,count(gender) female from city where gender='f' group by city,gender)b
on a.city=b.city

Q.What is Sequences?
Sequences are used for generating sequence numbers without any overhead of locking. Drawback is that after generating a sequence number if the transaction is rolled back, then that sequence number is lost

Q.What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
% TYPE provides the data type of a variable or a database column to that variable.
% ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
The advantages are : I. Need not know about variable's data type
ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.

Q.What is Mutating SQL Table?
Mutating Table is a table that is currently being modified by an Insert, Update or Delete statement. Constraining Table is a table that a triggering statement might need to read either directly for a SQL statement or indirectly for a declarative Referential Integrity constraints. Pseudo Columns behaves like a column in a table but are not actually stored in the table. E.g. Currval, Nextval, Rowid, Rownum, Level etc.

Q.What is PL/SQL table ?
Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.
Cursors
PL/SQL tables are PL/SQL?s way of providing arrays. Arrays are like tem-porary
tables in memory and thus are processed very quickly. It is impor-tant
for you to realize that they are not database tables, and DML
statements cannot be issued against them. This type of table is indexed
by a binary integer counter (it cannot be indexed by another type of
number) whose value can be referenced using the number of the index.
Remember that PL/SQL tables exist in memory only, and therefore don't
exist in any persistent way, disappearing after the session ends.
A PL/SQL TABLE DECLARATION
There are two steps in the declaration of a PL/SQL table. First, you must define the table structure using the TYPE statement. Second, once a table type is created, you then declare the actual table.
FOR EXAMPLE
DECLARE
-- Table structure definition
TYPE NameType IS TABLE OF
Customer.name_name%TYPE
INDEX BY BINARY_INTEGER;
-- Create the actual table
CnameTab NameType;
KnameTab NameType;
BEGIN
NULL; -- ...
END;

Q.In a Distributed Database System Can we execute two queries simultaneously? Justify?
Yes, Distributed database system based on 2 phase commit,one query is independent of 2 nd query so of course we can run.

Q.What are the modes of parameters that can be passed to a procedure ?
IN parameter is the default mode which acts as a constant inside calling environment.value passed in this parameter can not be changed.OUT parameter mode is used to pass value from calling environment into main block,here we can change the value.It acts as a variable inside calling environment.
INOUT parameter mode which pass value into calling environment and will get the value back in main block.
IN parameter mode uses call by reference method to pass value from formal parameter to actual parameter.
OUT & INOUT parameter mode uses call by value method to pass values.
IN,OUT,IN-OUT parameters.

Q.Name the tables where characteristics of Package, procedure and functions are stored?
User_objects, User_Source and User_error.

Q.How many types of database triggers can be specified on a table? What are they?
Insert Update Delete
Before Row o.k. o.k. o.k.
After Row o.k. o.k. o.k.
Before Statement o.k. o.k. o.k.
After Statement o.k. o.k. o.k.
If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.
If WHEN clause is specified, the trigger fires according to the returned Boolean value.

Q.How can a function retun more than one value in oracle with proper example?
Basically as per property of function it has to return one value. So the other values can be returned from the out parameter of the function.
But its advised if you want more that one return value go for procedure however function will also yield the same result.

Q.Explain If the entire disk is corrupted how will you and what are the steps to recover the database?
if the entire disk is corrupted and no backup is there don nothing sit and relax their is no possibility of recovery ...a backup is required for restoration and for recovery redo log and archive logs.
Once if you have theses than think of recovering ..a dba should always plan for the recovery scenario depending upon the criticality of the database.oracle provides 0% data loss facilty through data guard and online backup .its dba who has to decide.

Q.What is Rollback?

Rollback causes work in the current transaction to be undone.

Q.What is a cursor for loop ?
Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes when all the records have been processed.
eg. FOR emp_rec IN C1 LOOP
salary_total := salary_total +emp_rec sal;
END LOOP;

Q.How to sort the rows in SQL?
Sort the Rows:
SELECT column1, column2, ... FROM table_name ORDER BY columnX, columnY, ..
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC
SELECT column1, column2, ... FROM table_name ORDER BY columnX DESC, columnY ASC1.
select column1,column2,column3 from table1
where
column1>10
order by 1,3,2;
Inthis case it sorts based on the columns' position in the select query i.e. in the above query it will sort first based on column1 then on column3 and then by column2. By default the sort is in ascending order, if you want it to be in descending order, you need to specify the key word DESC in ORDER BY clause.
2.select * from emp order by eno desc;
You can sort your results based on any column in the tables because you are select all the columns.
3.select eno,ename from emp order by deptno;
This is wrong because the column deptno is not present in the select clause.

Q.What is Pragma EXECPTION_INIT? Explain the usage?
The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number

Q.What's the use of dyanamic sql in oracle?
Dynamic SQL enables you to write programs that reference SQL statements whose full text is not known until runtime.

Q.How we can create a table in PL/SQL block. insert records into it? is it possible by some procedure or function? please give example?
CREATE OR REPLACE PROCEDURE ddl_create_proc (p_table_name IN VARCHAR2)
AS
l_stmt VARCHAR2(200);
BEGIN
DBMS_OUTPUT.put_line('STARTING ');
l_stmt := 'create table '|| p_table_name || ' as (select * from emp )';
execute IMMEDIATE l_stmt;
DBMS_OUTPUT.put_line('end ');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line('exception '||SQLERRM || 'message'||sqlcode);
END;

Q.What is a JOIN?
JOIN is the form of SELECT command that combines info from two or more tables.
Types of Joins are Simple (Equijoin & Non-Equijoin), Outer & Self join.
Equijoin returns rows from two or more tables joined together based upon a equality condition in the WHERE clause.
Non-Equijoin returns rows from two or more tables based upon a relationship other than the equality condition in the WHERE clause.
Outer Join combines two or more tables returning those rows from one table that have no direct match in the other table.
Self Join joins a table to itself as though it were two separate tables.

Q.what is the starting oracle error number?
what is meant by forward declaration in functions?
One must declare an identifier before referencing it. Once it is declared it can be referred even before defining it in the PL/SQL. This rule applies to function and procedures also.

Q.Can we declare a column having number data type and its scale is larger than pricesion
ex: column_name NUMBER(10,100),
column_name NUMBAER(10,-84)
No, you cant. May be your table might be created successfully but if you try to insert values it will shows you an error.
Numeric or Value Error
NUMBER (p,s)
p- precision, which is the total size of digits
s- scale , which represents the total number of digits that are present to the right side of the decimal.
s should be strictly less than p. If I am missing somthing. Please fill me in.
Yes,we can declare a column with above condition.table created successfully.
yes, 100 is the total size and 10 is included in 100

Q.Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger? Why?
It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.
yes WE can use COMMIT and ROLLBACK triggers, but by using PRAGAMA AUTONAMOUS_TRANSATIONS. Now the transation treated as a autonomous tansation.

Q.What is COLUMN?
COLUMN command define column headings & format data values.

Q.SELECT statements in SQL?
SELECT column_name(s) FROM table_name
SELECT DISTINCT column_name(s) FROM table_name
SELECT column FROM table WHERE column operator value
SELECT column FROM table WHERE column LIKE pattern
SELECT column,SUM(column) FROM table GROUP BY column
SELECT column,SUM(column) FROM table GROUP BY column HAVING SUM(column) condition value
Note that single quotes around text values and numeric values should not be enclosed in quotes. Double quotes may be acceptable in some databases.

Q.What is the Delete Statements in SQL?
Delete statement in SQL is used to delete partial/all data.
Especially delete statement is useful in case of partial delete depending upon our criterias otherwise use TRUNCATE to delete whole data from table.
When delete command fires then:
1) Triggers will fire (If created on that table)
2) This will not auto commit changes made So there is one chance to rollback.
3) If u delete whole data then HWM (Highest Water Mark) will not change which gets changed in case of Truncate.

Q.What is Posting?
Posting is an event that writes Inserts, Updates & Deletes in the forms to the database but not committing these transactions to the database.

Q.Where the Pre_defined_exceptions are stored?
In the standard package.
Procedures, Functions & Packages ;

Q.What are two parts of package?
The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY. Package Specification contains declarations that are global to the packages and local to the schema.
Package Body contains actual procedures and local declaration of the procedures and cursor declarations.

Q.What are the datatypes a available in PL/SQL?
Some scalar data types such as
NUMBER,
VARCHAR2,
DATE,
CHAR,
LONG,
BOOLEAN.
Some composite data types such as RECORD & TABLE.

Q.What is an Exception? What are types of Exception?
Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
CURSOR_ALREADY_OPEN
DUP_VAL_ON_INDEX
NO_DATA_FOUND
TOO_MANY_ROWS
INVALID_CURSOR
INVALID_NUMBER
LOGON_DENIED
NOT_LOGGED_ON
PROGRAM-ERROR
STORAGE_ERROR
TIMEOUT_ON_RESOURCE
VALUE_ERROR
ZERO_DIVIDE
OTHERS.
exception is an identifier and error handling part of pl/sql types := 1)predifined 2) user defined.

Q.Explian rowid, rownum?what are the psoducolumns we have?
ROWID - Hexa decimal number each and every row having unique.Used in searching.
ROWNUM - It is a integer number also unique for sorting Normally TOP N Analysys.
Other Psudo Column are
NEXTVAL,CURRVAL Of sequence are some exampls
psudo columns are default columns provided by oracle

Q.How to avoid using cursors? What to use instead of cursor and in what cases to do so?
Just use subquery in for clause
ex:For emprec in (select * from emp)
loop
dbms_output.put_line(emprec.empno);
end loop;
no exit statement needed
implicit open,fetch,close occurs

Q.what is the starting oracle error number?
what is meant by forward declaration in functions?
One must declare an identifier before referencing it. Once it is declared it can be referred even before defining it in the PL/SQL. This rule applies to function and procedures also
ORA-20000

Q.What are the components of a PL/SQL block?
A set of related declarations and procedural statements is called block.
DECLARE -- declaration section BEGIN -- executable statements -- main section EXCEPTION -- handling possible exceptions -- occuring in the main section END;

Q.What is difference between stored procedures and application procedures,stored function and application function?
Stored procedures are sub programs stored in the database and can be called & execute multiple times where in an application procedure is the one being used for a particular application same is the way for function
Procedure:-
Execute as a PL/SQL
statement,No RETURN clause in
the header,Can return none, one,
or many values,Can contain a RETURN
statement
Function:-Invoke as part of an
expression,Must contain a RETURN
clause in the header,Must return a single value,Must contain at least one RETURN statement

Q.What is Raise_application_error ?
Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database
trigger.

Q.What is trigger,cursor,functions in pl-sql and we need sample programs about it?
Trigger is an event driven PL/SQL block. Event may be any DML transaction.
Cursor is a stored select statement for that current session. It will not be stored in the database, it is a logical component.
Function is a set of PL/SQL statements or a PL/SQL block, which performs an operation and must return a value.

Q.How we can create a table in PL/SQL block. insert records into it??? is it possible by some procedure or function?? please give example...
CREATE OR REPLACE PROCEDURE ddl_create_proc (p_table_name IN VARCHAR2)
AS
l_stmt VARCHAR2(200);
BEGIN
DBMS_OUTPUT.put_line('STARTING ');
l_stmt := 'create table '|| p_table_name || ' as (select * from emp )';
execute IMMEDIATE l_stmt;
DBMS_OUTPUT.put_line('end ');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line('exception '||SQLERRM || 'message'||sqlcode);
END;

Q.In pl/sql functions what is use of out parameter even though we have return statement.
With out parameters you can get the more than one out values in the calling program. It is recommended not to use out parameters in functions. If you need more than one out values then use procedures instead of functions.

Q.How to debug the procedure ?
You can use DBMS_OUTPUT oracle supplied package or DBMS_DEBUG pasckage.

Q.What is ref cursor?
In PL/SQL ,pointer has a datatype REF X where
REF-Reference
X-class of objects
Cursor Variables has a datatype REF-CURSOR
where Cursor Varibales are like pointers which hold the memory location of some item instead of the item itself.

Q.State the advantage and disadvantage of Cursor?
Advantage :
In pl/sql if you want perform some actions more than one records you should user these cursors only. bye using these cursors you process the query records. you can easily move the records and you can exit from procedure when you required by using cursor attributes.
disadvantage:

using implicit/explicit cursors are depended by sutiation. if the result set is les than 50 or 100 records it is better to go for implicit cursors. if the result set is large then you should use exlicit cursors. other wise it will put burdon on cpu.

Q.What is a database trigger ? Name some usages of database trigger ?
A database triggers is stored PL/SQL program unit associated with a specific database table or view. The code in the trigger defines the action the database needs to perform whenever some database manipulation (INSERT, UPDATE, DELETE) takes place.
Unlike the stored procedure and functions, which have to be called explicitly, the database triggers are fires (executed) or called implicitly whenever the table is affected by any of the above said DML operations.
Till oracle 7.0 only 12 triggers could be associated with a given table, but in higher versions of Oracle there is no such limitation. A database trigger fires with the privileges of owner not that of user
A database trigger has three parts
1. A triggering event
2. A trigger constraint (Optional)
3. Trigger action
A triggering event can be an insert, update, or delete statement or a instance shutdown or startup etc. The trigger fires automatically when any of these events occur A trigger constraint specifies a Boolean expression that must be true for the trigger to fire. This condition is specified using the WHEN clause. The trigger action is a procedure that contains the code to be executed when the trigger fires.
Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.

Q.What are the return values of functions SQLCODE and SQLERRM ?
SQLCODE returns the latest code of the error that has occurred.
SQLERRM returns the relevant error message of the SQLCODE.

Q.How packaged procedures and functions are called from the following?
a. Stored procedure or anonymous block
b. an application program such a PRC *C, PRO* COBOL
c. SQL *PLUS
a.PACKAGE NAME.PROCEDURE NAME (parameters);
variable := PACKAGE NAME.FUNCTION NAME (arguments);
EXEC SQL EXECUTE
b.
BEGIN
PACKAGE NAME.PROCEDURE NAME (parameters)
variable := PACKAGE NAME.FUNCTION NAME (arguments);
END;
END EXEC;
c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any out/in-out parameters. A function can not be called.

Q.Operators used in SELECT statements are?
= Equal
<> or != Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern

Q.Give the structure of the procedure ?
basically procedure has three
parts
1.variable declaretion(optional)
2.body(mandetory)
3.Exception(optional)
suppose ex
CREATE OR REPLACEPROCEDURE emp_pro( p_id IN employees.employee_id%TYPE)
IS
v_name employees.last_name%TYPE;
v_mail employees.email%TYPE;
BEGIN
SELECT last_name,email INTO v_name,v_mail FROM employees
WHERE employee_id:=p_id;
DBMS_OUTPUT.PUT_LINE('NAME:'||v_name ||'MAILID:'||v_mail);
END;
/
PROCEDURE name (parameter list.....)
is
local variable declarations
BEGIN
Executable statements.
Exception.
exception handlers
end;

Q.What is SPOOL?
spool command used for printing the out put of the sql statments in a file. Eg.
spool /tmp/sql_out.txt
select emp_name, emp_id from emp where dept='sales';
spool off;
we can see the out on /tmp/sql_out.txt file.
SPOOL command creates a print file of the report.

Q.What are advantages fo Stored Procedures

Extensibility,Modularity, Reusability, Maintainability and one time compilation.

Q.IS Stored Function Is Pre-Compiled as Stored Procedure ? If No Why
stored procedure means the pre-compiled precedure ,which is used for a specific action to be executed more than one times whenever you called from coding in the programe.
stored procedure is an important concept in the application developement in oracle.

Q.Explain the two type of Cursors ?
There are two types of cursors, Implicit Cursor and Explicit Cursor.
PL/SQL uses Implicit Cursors for queries. User defined cursors are called Explicit Cursors. They can be declared and used.

Q.What is Overloading of procedures ?
Overloading of procedure
name of the procedure is
same but the number of parameters should be different.In that case,procedure will be overloaded.
2. if the number of parameters are same in that case,data type should be different.
if the two rules are satisfied in that case procedure will be overloaded.

Q.What is PL/SQL ?
PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.

Q.What are the PL/SQL Statements used in cursor processing ?
DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.

Q.What is Set Transaction?
Set Transaction is to establish properties for the current transaction.

Q.What is Character Functions?
Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional functions are GREATEST & LEAST. Group Functions returns results based upon groups of rows rather than one result per row, use group functions. They are AVG, COUNT, MAX, MIN & SUM.

Q.What is an Exception ? What are types of Exception? 

Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
CURSOR_ALREADY_OPEN
DUP_VAL_ON_INDEX
NO_DATA_FOUND
TOO_MANY_ROWS
INVALID_CURSOR
INVALID_NUMBER
LOGON_DENIED
NOT_LOGGED_ON
PROGRAM-ERROR
STORAGE_ERROR
TIMEOUT_ON_RESOURCE
VALUE_ERROR
ZERO_DIVIDE
OTHERS.

Q.Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger? Why?
 

It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.
yes WE can use COMMIT and ROLLBACK triggers, but by using PRAGAMA AUTONAMOUS_TRANSATIONS. Now the transation treated as a autonomous tansation.

Q.What is Multiple columns? 

Multiple columns can be returned from a Nested Subquery.

Q.What is Savepoint? 

Savepoint is a point within a particular transaction to which you may rollback without rolling back the entire transaction.