Friday, October 11, 2013

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.

Thursday, August 22, 2013

Oracle Forms 4.0 Interview Questions and Answers

1. Give the Types of modules in a form?
- Form
- Menu
- Library
 
2. Write the Abbreviation for the following File Extension
1. FMB
2. MMB
3. PLL

FMB ----- Form Module Binary.
MMB ----- Menu Module Binary.
PLL ------ PL/SQL Library Module Binary.
 
3. What are the design facilities available in forms 4.0?
Default Block facility.
Layout Editor.
Menu Editor.
Object Lists.
Property Sheets.
PL/SQL Editor.
Tables Columns Browser.
Built-ins Browser.
 
4. What is a Layout Editor?
The Layout Editor is a graphical design facility for creating and arranging items and boilerplate text and graphics objects in your application's interface.
 
5. What do you mean by a block in forms4.0?
Block is a single mechanism for grouping related items into a functional unit for storing,displaying and manipulating records.
6. Explain types of Block in forms4.0?
Base table Blocks.
Control Blocks.
1. A base table block is one that is associated with a specific database table or view.
2. A control block is a block that is not associated with a database table.
 
7. What are the options available to refresh snapshots?
COMPLETE - Tables are completely regenerated using the snapshot's query and the master tables every time the snapshot referenced.
FAST - If simple snapshot used then a snapshot log can be used to send the changes to the snapshot  tables.
FORCE - Default value. If possible it performs a FAST refresh; Otherwise it will perform a complete refresh.
 
8. List the Types of tems?
Text item.
Chart item.
Check box.
Display item.
Image item.
List item.
Radio Group.
User Area item.
 
9. What is a Navigable item?
A navigable item is one that operators can navigate to with the keyboard during default navigation, or that Oracle forms can navigate to by executing a navigational
built-in procedure.
 
10. Can you change the color of the push button in design time?
No.
 
11. What is a Check Box?
  A Check Box is a two state control that indicates whether a certain condition or value is on or off, true or false. The display state of a check box is always either "checked" or "unchecked".
 
12. What are the triggers associated with a check box?
Only When-checkbox-activated Trigger associated with a Check box.
 
13. What is a display item?
Display items are similar to text items but store only fetched or assigned values. Operators cannot navigate to a display item or edit the value it contains.
 
14. What is a list item?
It is a list of text elements.
 
15. What are the display styles of list items?
Poplist, No text Item displayed in the list item.
Tlist, No element in the list is highlighted.
 
16. What is a radio Group?
Radio groups display a fixed no of options that are mutually exclusive. User can select one out of n number of options.
 
17. How many maximum number of radio buttons can you assign to a radio group?
Unlimited no of radio buttons can be assigned to a radio group
 
18. Can you change the default value of the radio button group at run time?
No.
 
19. What triggers are associated with the radio group?
Only when-radio-changed trigger associated with radio group
 
20. What is a visual attribute?
Visual Attributes are the font, color and pattern characteristics of objects that operators see and intract with in our application.
 
21. What are the types of visual attribute settings?
Custom Visual attributes
Default visual attributes
Named Visual attributes.
 
22. What is a window?
A window, byitself, can be thought of as an empty frame. The frame provides a way to intract with the window, including the ability to scroll, move, and resize the window. The content of the window ie. what is displayed inside the frame is determined by the canvas
View or canvas-views displayed in the window at run-time.
 
23. What are the differrent types of windows?
Root window,
Secondary window.
 
24. Can a root window be made modal?
No.
 
25. List the buil-in routine for controlling window during run-time?
Find_window,
get_window_property,
hide_window,
move_window,
resize_window,
set_window_property,
show_View
 
26. List the windows event triggers available in Forms 4.0?
When-window-activated, when-window-closed, when-window-deactivated, when-window-resized
 
27. What built-in is used for changing the properties of the window dynamically?
Set_window_property
 
28. What is a canvas-view?
A canvas-view is the background object on which you layout the interface items (text-items, check boxes, radio groups, and so on.) and boilerplate objects that operators see and interact with as they run your form. At run-time, operators can see only those items that have been assiged to a specific canvas. Each canvas, in term, must be displayed in a specfic window.
 
29. Give the equivalent term in forms 4.0 for the following.
Page, Page 0?
Page - Canvas-View
Page 0 - Canvas-view null.
 
30. What are the types of canvas-views?
Content View, Stacked View.
 
31. What is the content view and stacked view?
A content view is the "Base" view that occupies the entire content pane of the window in which it is displayed.
A stacked view differs from a content canvas view in that it is not the base view for the window to which it is assigned
 
32. List the built-in routines for the controlling canvas views during run-time?
Find_canvas
Get-Canvas_property
Get_view_property
Hide_View
Replace_content_view
Scroll_view
Set_canvas_property
Set_view_property
Show_view
 
33. What is an Alert?
An alert is a modal window that displays a message notifies the operator of some application condition
 
34. What are the display styles of an alert?
Stop, Caution, note
 
35. Can you attach an alert to a field?
No
 
36. What built-in is used for showing the alert during run-time?
Show_alert.
 
37. Can you change the alert messages at run-time? If yes, give the name of th built-in to chage the alert messages at run-time.
Yes.
Set_alert_property.
 
40. What is the built-in function used for finding the alert?
Find_alert
 
41. List the editors availables in forms 4.0?
Default editor
User_defined editors
system editors.
 
42. What built-in routines are used to display editor dynamicaly?
Edit_text item
show_editor
 
43. What is a Lov?
A list of values is a single or multi column selection list displayed in a pop-up window
 
44. Can you attach a lov to a field at design time?
Yes.
 
45. Can you attach a lov to a field at run-time? If yes, give the build-in name.
Yes.
Set_item_proprety
 
46. What is the built-in used for showing lov at runtime?
Show_lov
 
47. What is the built-in used to get and set lov properties during run-time?
Get_lov_property
Set_lov_property
 
48. What is a record Group?
A record group is an internal oracle forms data structure that has a simillar column/row frame work to a database table
 
49. What are the different types of a record group?
Query record group
Static record group
Non query record group
 
50. Give built-in routine related to record groups?
Create_group (Function)
Create_group_from_query(Function)
Delete_group(Procedure)
Add_group_column(Function)
Add_group_row(Procedure)
Delete_group_row(Procedure)
Populate_group(Function)
Populate_group_with_query(Function)
Set_group_Char_cell(procedure)
 
51. What is the built_in routine used to count the no of rows in a group?
Get_group _row_count
 
52. List system variables available in forms 4.0, and not available in forms 3.0?
System.cordination_operation
System Date_threshold
System.effective_Date
System.event_window
System.suppress_working
 
53. System.effective_date system variable is read only True/False
False
 
54. What is a library in Forms 4.0?
A library is a collection of Pl/SQL program units, including user named procedures, functions & packages
 
55. Is it possible to attach same library to more than one form?
Yes
 
56. Explain the following file extention related to library?
.pll,.lib,.pld
The library pll files is a portable design file comparable to an fmb form file
The library lib file is a plat form specific, generated library file comparable to an fmx form file
The pld file is Txt format file and can be used for source controlling your library files
 
57. How do you pass the parameters from one form to another form?
To pass one or more parameters to a called form, the calling form must perform the following steps in a trigger or user named routine excute the create_parameter_list built_in function to programatically.
Create a parameter list to execute the add parameter built_in procedure to add one or more parameters list.
Execute the call_form, New_form or run_product built_in procedure and include the name or id of the parameter list to be passed to the called form.
 
58. What are the built-in routines is available in forms 4.0 to create and manipulate a parameter list?
Add_parameter
Create_Parameter_list
Delete_parameter
Destroy_parameter_list
Get_parameter_attr
Get_parameter_list
set_parameter_attr
 
59. What are the two ways to incorporate images into a oracle forms application?
Boilerplate Images
Image_items
 
60. How image_items can be populate to field in forms 4.0?
A fetch from a long raw database column PL/Sql assignment to executing the read_image_file built_in procedure to get an image from the file system.
 
61. What are the triggers associated with the image item?
When-Image-activated(Fires when the operator double clicks on an image Items)
When-image-pressed(fires when the operator selects or deselects the image item)
 
62. List some built-in routines used to manipulate images in image_item?
Image_add
Image_and
Image_subtract
Image_xor
Image_zoom
 
63. What are the built_in used to trapping errors in forms 4?
Error_type return character
Error_code return number
Error_text return char
Dbms_error_code return no.
Dbms_error_text return char
 
64. What is a predefined exception available in forms 4.0?
Raise form_trigger_failure
 
65. What are the menu items that oracle forms 4.0 supports?
Plain, Check,Radio, Separator, Magic   
Interview questions and answers for Oracle database Oracle Forms 4.0 Interview Questions and Answers
Oracle Forms 4.0 Interview Questions and Answers includes, visual attribute, visual attribute settings, window, root window, event triggers, canvas-view, Alert, display styles of an alert, Lov, showing lov at runtime, record Group, System Variables, library, Pl/SQL program units, file extension, pass the parameters, built-in routines, incorporate images into a oracle, trapping errors, predefined exception, menu items, Layout Editor, Types of modules, design facilities, block, types of Block, Navigable item.

Friday, July 19, 2013

Oracle 11g dba interview questions and answers - PL SQL Interview Question

22) What is System Activity Reporter (SAR) and SHMMAX?

• SAR is a utility to display resource usage on the UNIX system.
• sar –u shows CPU activity.
• Sar –w shows swapping activity
• Sar –b shows buffer activity
• SHMMAX is the maximum size of a shared memory segment on a Linux system.

 

23) List out some major environment variable used in installation?

• ORACLE_BASE=/u01/app/<installation-directory>
• ORACLE_HOME=$ORACLE_BASE/product/11.2.0(for 11g)/dbhome_1
• ORACLE_SID=<instance-name>
• PATH=$ORACLE_HOME/bin:$PATH
• LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
• TNS_ADMIN=$ORACLE_HOME/network/admin
• These are absolutely critical environment variables in running OUI.

 

24) What is a control file?

• Control file is a binary file which records the physical structure of a database.
• It includes number of log files and their respective location, Database name and timestamp when database is created, checkpoint information.
• We find CONTROL_FILE parameter in initialization parameter file which stores information about control file location.
• We can multiplex control files, store in different locations to make control files available even if one is corrupted.
• We can also avoid the risk of single point of failure.

 

25) At what stage of instance, control file information is read and can we recover control file and how to know information in a control file?

• During database mounting, control file information is read.
• We can’t recover or restore lost control file, but we can still startup the database using control files created using multiplexing in different locations.
• We can query the following command
SQL> alter database backup controlfile to trace;
• We find a trace file(.trc) in udump location,we can edit it and find the complete database structure.
• Multiplexing can also be done using Following command
SQL> alter database backup controlfile to <Different location/path>.

 

26) How can you obtain Information about control file?

• Control file information can be shown in initialization parameter file.
• We can query v$controlfile to display the names of control files
• From sql we can execute
SQL> show parameter control_files;
• The above query gives the name, Location of control files in our physical disk.
• We can edit PFILE using a vi editor and control_files parameter gives us information about number of and location of control files.

 

27) How do you resize a data file and tablespace?

• Prior to Oracle 7.2 you can’t resize a datafile.
• The solution was to delete the tablespace, recreating it with different sized datafiles.
• After 7.2 you can resize a datafile by using ALTER DATABASE DATAFILE <file_name> RESIZE;
• Resizing Table space includes creation of new data file or resizing existing data file.
• ALTER TABLESPACE <tablespacename> ADD DATAFILE ‘<datafile name> ‘ size M; creates a new datafile.

 

28) Name the views used to look at the size of a datafile, controlfiles, block size, determine free space in a tablespace ?

• DBA_DATA_FILES or v$datafile view can be used to look at the size of a datafile .
• DBA_FREE_SPACE is used to determine free space in a tablespace.
• V$contolfile used to look at the size of a control file which includes maxlogfiles, maxlogmembers, maxinstances.
• Select * from v$controlfile gives the size of a controlfile.
• From sqlplus, query show parameter block_size to get size of db_block_size.

29) What is archive log file?

• In archive log mode, the database will makes archive of all redo log files that are filled, called as archived redo logs or archive log files.

• By default your database runs in NO ARCHIVE LOG mode, so we can’t perform online backup’s (HOT backup).
• You must shut down database to perform clean backup (COLD backup) and recovery can be done to the previous backup state.
• Archive log files are stored in a default location called FRA (Flash Recovery Area).
• We can also define our own backup location by setting log_archive_dest parameter.

 

30) Assume you work in an xyz company as senior DBA and on your absence your back up DBA has corrupted all the control files while working with the ALTER DATABASE BACKUP CONTROLFILE command. What do you do?

• As long as all data files are safe and on a successful completion of BACKUP control file command by your Back up DBA you are in safe zone.
• We can restore the control file by performing following commands
1) CONNECT INTERNAL STARTUP MOUNT
2) TAKE ANY OFFLINE TABLESPACE (Read-only)
3) ALTER DATABASE DATAFILE (OFFLINE)
4) RECOVER DATABASE USING BACKUP CONTROL FILE
5) ALTER DATABASE OPEN RESETLOGS
6) BRING READ ONLY TABLE SPACE BACK ONLINE


• Shutdown and back up the system. Then restart.

• Then give the command ALTER DATABSE BACKUP CONTROL FILE TO TRACE

• This output can be used for control file recovery as well.

If control file backup is not available, then the following will be required

1) CONNECT INTERNAL STARTUP NOMOUNT
2) CREATE CONTROL FILE .....;
• But we need to know all of the datafiles, logfiles, and settings of MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES for the database to use the command.

 

31) Can we reduce the space of TEMP datafile? How?

• Yes, we can reduce the space of the TEMP datafile.

• Prior to oracle 11g,,you had to recreate the datafile.


• In oracle 11g you reduce space of TEMP datafile by shrinking the TEMP tablespace.It is a new feature to 11g.

• The dynamic performance view can be very useful in determining which table space to shrink.

 

32) What do you mean by database backup and which files must be backed up?

• Database stores most crucial data of business ,so it’s important to keep the data safe and this can be achieved by backup.
• The following files must be backed up

• Database files (Header of datafiles is freezed during backup)
• Control files
• Archived log files
• Parameter files (spfile and pfile)
• Password file

 

33) What is a full backup and name some tools you use for full backup?

• A full backup is a backup of all the control files, data files, and parameter file (SPFILE or PFILE).
• You must also backup your ORACLE_HOME binaries which are used for cloning.
• A full backup can be performed when our database runs in NON ARCHIVE LOG mode.
• As a thumb rule, you must shutdown your database before you perform full backup.
• Full or COLD backup can be performed by using copy command in unix.

 

34) What are the different types of backup’s available and also explain the difference between them?

• There are 2 types of backup’s

1) COLD backup(User managed & RMAN)
2) HOT backup(User managed & RMAN)

• Hot backup is taken when the database is still online and database should be in ARCHIVE LOG MODE.
• Cold backup is taken when the database is in offline mode.
• Hot backup is inconsistent backup where as cold backup is consistent backup.
• You can begin backup by using the following command
SQL> alter database begin backup;
• End backup by
SQL> alter database end backup;

 

35) How to recover database if we lost the control file and we do not have a backup and what is RMAN?

• We can recover our database at any point of time, when we have backup of our control files in different mount points.
• Also check whether the control file is available in trace file located in USERDUMP or the alert log to recover the database.
RMAN

• RMAN called as Recovery manager tool supplied by oracle that can be used to manage backup and recovery activities.
• You can perform both offline (Cold) and online (Hot) backup’s using RMAN.
• We need to configure Flash_Recovery_Area of database to use RMAN.
• RMAN maintains the repository of backup information in control file.

 36) Name the architectural components of RMAN

• RMAN executable
• Server process
• Channels
• Target database
• Recovery catalog database
• Media management layer
• Backup sets and backup pieces

 

37) What is a recovery catalog?

• Recovery catalog is an inventory of backup taken by RMAN for the database.
• The size of the recovery catalog schema depends upon the number of databases monitored by the catalog.
• It is used to restore a physical backup, reconstruct it, and make it available to the oracle server.
• RMAN can be used without recovery catalog.
• Recovery catalog also holds RMAN stored scripts.

 

38) List some advantages of using RMAN.

• Table spaces are not put in the backup mode ,therefore there is no extra redo log file during online backups.
• Incremental backups that only copy data blocks, which have changed since last backup.
• Detection of corrupt blocks.
• Built in reporting and listing commands.
• Parallelization of I/O operations.

 

39) How to bring a database from ARCHIVE LOG mode to NON ARCHIVE LOG MODE?

• You should change your init<SID>.ora file with the following information
• log_archive_dest=’/u01/oradata/archlog’ (for example)
• log_archive_format=’%t_%s.dbf’
• log_archive_start=true (prior to 10g)
• sql>shutdown;
• sql> startup mount;
• sql> alter database archivelog;
• sql>alter database open;
• Make sure you backup your database before switching to ARCHIVELOG mode.

 

40) What are the different stages of database startup?

• Database undergoes different stages before making itself available to end users
• Following stages are involved in the startup of database
? NoMount
? Mount
? Open

• NoMount – Oracle Instance is available based on the parameters defined in SPFile.
• Mount - Based on the Information from parameter control files location in spfile, it opens and reads them and available to next stage.
• Open - Datafiles, redo log files are available to the end users.

 

41) Name some of the important dynamic performance views used in Oracle.

• V$Parameter
• V$Database
• V$Instance
• V$Datafiles
• V$controlfiles
• V$logfiles

 

42) What are the different methods we can shutdown our database?

• SHUTDOWN (or) SHUTDOWN NORMAL
No new connections are accepted and wait for the user to close the session.
• SHUTDOWN TRANSACTIONAL
No new connections are accepted and wait for the existing transactions to commit and logouts the session without the permission of user.
• SHUTDOWN IMMEDIATE
No new connections are accepted and all committed transactions are reflected in database and all the transactions are about to commit are rolled back to previous value.
• SHUTDOWN ABORT

It’s just like an immediate power off for a database, it doesn’t mind what are the transactions running it just stops entire activity -(even committed transactions are not reflected in database) and make database unavailable. SMON process takes responsibility for recovery during next startup of database.

• SHUTDOWN NORMAL, TRANSACTIONAL, IMMEDIATE are clean shutdown methods as database maintains its consistency.
• SHUTDOWN ABORT leaves our database in an inconsistent state,data integrity is lost.

 

43) What are the different types of indexes available in Oracle?

Oracle provides several Indexing schemas
• B-tree index – Retrieves a small amount of information from a large table.
• Global and Local index – Relates to partitioned tables and indexes.
• Reverse Key Index - It Is most useful for oracle real application clusters applications.
• Domain Index – Refers to an application
• Hash cluster Index – Refers to the index that is defined specifically for a hash cluster.

 

44) What is the use of ALERT log file? Where can you find the ALERT log file?

• Alert log file is a log file that records database-wide events which is used for trouble shooting.
• We can find the Log file in BACKGROUND_DUMP_DEST parameter.
• Following events are recorded in ALERT log file:
• Database shutdown and startup information.
• All non-default parameters.
• Oracle internal (ORA-600) errors.
• Information about a modified control file.
• Log switch change.

 

45) What is a user process trace file?

• It is an optional file which is produced by user session.
• It is generated only if the value of SQL_TRACE parameter is set to true for a session.
• SQL_TRACE parameter can be set at database, instance, or session level.
• If it set at instance level, trace file will be created for all connected sessions.
• If it is set at session level, trace file will be generated only for specified session.
• The location of user process trace file is specified in the USER_DUMP_DEST parameter.

 

46) What are different types of locks?

There are different types of locks, which are given as follows:
• System locks – controlled by oracle and held for a very brief period of time.
• User locks – Created and managed using dbms_lock package.
• Different types of user locks are given as follows

• UL Lock – Defined with dbms_lock package.
• TX Lock – Acquired once for every transaction. It isa row transaction lock.
• TM Lock – Acquired once for each object, which is being changed. It is a DML lock. The ID1 column identifies the object being modified.

 

47) What do db_file_sequential_read and db_file_scattered_read events define?

• Db_file_sequential_read event generally indicates index usage.
• It shows an access by row id.
• While the db_file-scattered_read event indicates full table scan.
• Db_file_sequential_read event reads a single block at one time.
• Whereas db_file_scattered_read event reads multiple blocks.

 

48) What is a latch and explain its significance?

• Latch is an on/off switch in oracle that a process must access in order to perform certain type of activities.
• They enforce serial access to the resources and limit the amount of time for which a single process can use a resource.
• A latch is acquired for a very short amount of time to ensure that the resource is allocated.
• We may face performance issues which may be due to either of the two following reasons
• Lack of availability of resource.
• Poor application programming resulting in high number of requests for resource.
• Latch information is available in the v$LATCH and v$LATCHHOLDER dynamic performance views.

49) Explain the architecture of data guard?

Data guard architecture includes the following components

• Primary database – Refers to the production database.
• Standby Database – Refers to a copy of primary or production database.It may have more than one standby database.
• Log transport service – Manages transfer of archive log files primary to standby database.
• Network configuration – Refers to the network connection between primary and standby database.
• Applies archived logs to the standby database.
• Role management services – Manages the role change between primary and standby database.
• Data guard broker – Manages data guard creation process and monitors the dataguard.

50) What is role transition and when does it happen?

• Database operates in one of the following mutually exclusive roles
Primary
Standby
• Role transition is the change of role between primary and standby databases.
• Data guard enables you to change this roles dynamically by issuing the sql statements.
• Transition happens in between primary and standby databases in the following way
• Switchover, where primary database is switched to standby database and standby to primary database.
• Failover, where a standby database can be used as a disaster recovery solution in case of a failure in primary database.
• DRM allows you to create resource plans, which specify resource allocation to various consumer groups.
• DRM offers an easy-to-use and flexible system by defining distinct independent components.
• Enables you to limit the length of time a user session can stay idle and automatically terminates long-running SQL statement and users sessions.
• Sets the initial login priorities for various consumer groups.
• DRM will automatically queue all the subsequent requests until the currently running sessions complete.