You are on page 1of 17

Contents Q: What do u understand by database and what is objects in oracle Q: What is a table, view, snapshot? Q: Do a view contain data?

Q: What are the advantages of views? Q: What is an Oracle sequence? Q: What is a synonym? Q: What are the types of synonyms? Q: What is a private synonym? Q: What is a public synonym? Q: What is an Oracle inde ? Q: What is a schema? Q: What is difference between !"#$%&!' ( D')'!'? Q: What is a join? ' plain the different types of joins? Q: Difference between *#+*!" and ,$*!"? Q: What is difference between %-&" and .&"%-&"/? What is the ma imum *,0' allowed for each type? Q: -ow to access the current value and ne t value from a sequence? Q: What are the components of physical database structure of Oracle database? Q: What is schema? Q: Query to delete duplicate row from a table Q: What is three types of commands1statemets used in Oracle ? Q: What is a cursor its attribute and types? Q: What are inline views? Q: -ow can we refresh a snapshot? Q: What is a tablespace? Q: What is an Oracle sequence? Q: ,s sequence cyclic? Q: *elect nth highest value from a list of values ? Q: What are triggers and its types? Q: What is the ma imum number of triggers, can apply to a single table? Q: Difference between rowid and rownum? Q: What is the fastest query method for a table? Q: What is the difference of a )'2! 3O,$ and an ,$$'" 3O,$ statement? Q: -ow can , avoid a divide by 4ero error? Q: ,s view updatable? Q: What is Dual ? Q: What is the difference between %-&" and .&"%-&" ? Q: Do we use commit in triggers5 Q: -ow will the fetch the last inserted record in any table ? Q: What are constraints and its types? Q: What is "eferential ,ntegrity and "eferential integrity constraint ? Q: What is groups by and having clause? ' plain with e ample Q: What are )O%6*? What are types of different types of )oc7? Q: Difference between unique 7ey,primary 7ey and foreign 7ey ? Q: What are &dvantages of !"#$%&!' %ommand over D')'!'1D"O8 !&+)' %ommand ? Q: What are steps involved in ' ecution of *Q) statements? Q: What do you mean by 8arsing? Q: What is a -,$! and what are types -,$!? Q: What do u mean by '9%'8!,O$:,$,! 8ragma ? Q: What do u mean by 3*8 query? Q: Describe Oracle database;s physical and logical structure ? Q: What is <%hec7 %onstraints= and <with chec7 options= and <Default *pecification=? Q: What is the ma imum no5 of columns a table can have ? Q: %an a trigger written for a view ?

Q: What do u understand by database and what is objects in oracle


Ans: A database is defined as a collection of meaningful data. Objects in oracle means Table, Views, Procedures, Triggers, Synonym etc

Q: What is a table, view, snapshot?


Ans: Table:A table is the basic unit of data storage in an Oracle database. The tables of a database hold all of the user accessible data. Table data is stored in rows and columns. Views: A view is a virtual table. Every view has a uery attached to it. !The uery is a SE"E#T statement that identifies the columns and rows of the table!s$ the view uses.$ Snapshot: A Sna%shot is a recent co%y of a table from database or in some cases ,a subset of rows&columns of a table. 't is also (nown as Materialized view.

Q: Do a view contain data?


Ans: Views do not contain or store data

Q: What are the advantages of views?


Ans: Provide an additional level of table security, by restricting access to a %redetermined set of rows and columns of a table. ) *ide data com%le+ity. ) Sim%lify commands for the user. ) Present the data in a different %ers%ective from that of the base table. ) Store com%le+ ueries.

Q: What is an Oracle sequence?


Ans: A Sequence generates a serial list of uni ue numbers for numerical columns of a database,s tables.

Q: What is a synonym?
Ans: A synonym is an alias for a table, view, se uence or %rogram unit.

Q: What are the types of synonyms?


Ans: There are two ty%es of synonyms %rivate and %ublic.

Q: What is a private synonym?


Ans: Only its owner can access a %rivate synonym.

Q: What is a public synonym?


Ans: Any database user can access a %ublic synonym

Q: What is an Oracle index?


Ans: An inde+ is an o%tional structure associated with a table to have direct access to rows, which can be created to increase the %erformance of data retrieval. 'nde+ can be created on one or more columns of a table. 'nde+ may also be considered as a ordered list of content of a column.

Q: What is a schema?
Ans: The set of objects owned by user account is called the schema.

Q: What is difference between TRUNCATE & DELETE?


Ans: Differences: T-./#ATE commits after deleting entire table i.e., cannot be rolled bac(. 0atabase triggers do not fire on T-./#ATE 0E"ETE allows the filtered deletion. 0eleted records can be rolled bac( or committed. 0atabase triggers fire on 0E"ETE.

Q: What is a join? Explain the different types of joins?


Ans: 1oin is a uery, which retrieves related columns or rows from multi%le tables. Self Join - 1oining the table with itself. Equi Join - 1oining two tables by e uating two common columns. on-Equi Join - 1oining two tables by not e uating two common columns. !uter Join - 1oining two tables in such a way that uery can also retrieve rows that do not have corres%onding join value in the other table.

Q: Difference between SUBSTR and INSTR?


Ans: '/ST- !String2, String3 !n, !m$$, '/ST- returns the %osition of the m)th occurrence of the string 3 in string2. The search begins from nth %osition of string2. S.4ST- !String2 n, m$ S.4ST- returns a character string of si5e m in string2, starting from n)th %osition of string2.

Q: What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each type?
Ans: #*A- %ads blan( s%aces to the ma+imum length. VA-#*A-3 does not %ad blan(

s%aces. 6or #*A- the ma+imum length is 377 and 3888 for VA-#*A-3

Q: How to access the current value and next value from a sequence?
Ans: "urrent Value : Se uence name.#.--VA" e#t Value se uence name./E9TVA".

Q: What are the components of physical database structure of Oracle database?


Ans: Oracle database is com%rised of three ty%es of files. One or more datafiles, two are more redo log files, and one or more control files.

Q: What is schema?
Ans: A schema is collection of database objects of a user.

Q: Query to delete duplicate row from a table


Ans: 0elete from em% where rowid not in !Select min!rowid$ from em% :rou%by em%;de%t$

Q: What is three types of commands/statemets used in Oracle ?


Ans: DM$ state%ents : 0ata <anu%ulation "anguage Statements 6or eg= =insert,u%date,delete,select DD$ state%ents : 0ata 0efinition "anguage 6or eg= #reate , Alter ,0ro%,Truncate D"$ state%ent : 0ata #ontrol "anguage Statements 6or eg= :rant ,-evo(e ,commit,rollbac(

Q: What is a cursor its attribute and types?


Ans: The Oracle Engine uses a wor( area for its internal %rocessing in order to e+ecute an S>" statement. This wor( area is %rivate to S>" o%eration and is called #ursor. T&pes of "ursor: '%plicit "ursor: 'f the Oracle engine o%ened a cursor for its internal %rocessing then it is (now as im%licit cursor. 't is invo(ed im%licitly. E#plicit "ursor: A cursor which is o%ened for %rocessing data through a P"&S>" bloc( is (now as E+%licit #ursor. Attributes !f a '%plicit "ursor: ('S!)E ?returns T-.E if cursor is o%en else 6A"SE. Synta+ is S>"@'SOPE/ @-OA#O./T))) returns number of records %rocessed from cursor synta+ is S>" @-OA#O./T @6O./0)))) returns T-.E if record is fetched successfully else 6A"SE,

synta+ is S>"@6O./0 @/OT6O./0)) returns T-.E if record is not fetched successfully else 6A"SE synta+ is S>"@/OT6O./0 Attributes Of a E+%licit #ursor @'SOPE/?returns T-.E if cursor is o%en else 6A"SE. Synta+ is cursorname@'SOPE/ @-OA#O./T))) returns number of records %rocessed from cursor synta+ is cursorname @-OA#O./T @6O./0)))) returns T-.E if record is fetched successfully else 6A"SE, synta+ is cursorname @6O./0 @/OT6O./0)) returns T-.E if record is not fetched successfully else 6A"SE synta+ is cursorname @/OT6O./0

Q: What are inline views?


Ans: 'nline view is Sub) uery! ueries written in a where clause of S>" statements.$. 't is a uery whose return values are used in filtering conditions of the main uery.

Q: How can we refresh a snapshot?


Ans: -efreshing Sna%shots= A sna%shot can be refreshed automatically or manually. 'f a sna%shot has to be automatically refreshed then -E6-ES* clause must be s%ecified in the #-EATE S/APS*OT. The 6AST, #O<P"ETE or 6O-#E s%ecifies the ty%e of refresh used for automatic refresh. 6or automatic refresh we can s%ecify the STA-T A'T* and /E9T %arameter to decide the time interval for the ne+t u%date. #O<P"ETE -E6-ES*= 'n com%lete refresh the sna%shot uery is e+ecuted and %laces the result in the sna%shot. 6AST -E6-ES* = 'n this only the changes made to the master table will be u%dated to the sna%shot. The corres%onding log file is used to u%date. 6ast refresh will be done only if B The sna%shot is a sim%le sna%shot. B The sna%shot,s master table has a sna%shot log C B The sna%shot log was created before the sna%shot was last refreshed or created. 6O-#E -E6-ES* = 'n this O-A#"E decides how to refresh the sna%shot at the scheduled refresh time. 'f a fast refresh is %ossible it %erforms a fast refresh else it does a com%lete refresh.

Q: What is a tablespace?
Ans: A database is divided into "ogical Storage .nit called tables%aces. A tables%ace is used to grou%ed related logical structures together.

Q: What is an Oracle sequence?


Ans: A se uence generates a serial list of uni ue numbers for numerical columns of a database,s tables.

Q: Is sequence cyclic?
Ans: Des

Q: Select nth highest value from a list of values ?


Ans: SE"E#T a.em%;name,a.sal 6-O< em% a A*E-E En ) 2F !SE"E#T

#O./T!0'ST'/#T sal$ 6-O< em% b A*E-E b.sal G a.sal $

Q: What are triggers and its types?


Ans: A trigger is a %iece of code attached to a table that is e+ecuted after s%ecified 0<" statements e+ecuted on that table. There are 23 ty%es of triggers in P"&S>" that consist of combinations of the 4E6O-E, A6TE-, -OA, STATE<E/T, TA4"E, '/SE-T, .P0ATE, 0E"ETE and A"" (ey words= 6or eg= 4E6O-E A"" -OA '/SE-T A6TE- A"" -OA '/SE-T 4E6O-E '/SE-T A6TE- '/SE-T

Q: What is the maximum number of triggers, can apply to a single table?


Ans: 23 triggers!Oracle$.

Q: Difference between rowid and rownum?


Ans: -OA'0 is %seudo column in every table. The %hysical address of the rows is use to for the -OA'0.'/ *E9A0E#'<A" re%resentation, -OA'0 is shown as 2H character string of the following format 444444444.----.6666 !bloc(, row, file$ 6666 is the 6ile'0 of the datafile that contains the row. 444444444 is the address of the databloc( within the datafile that contains the row. ---- is the -OA /.<4E- with the data bloc( that contains the row. They are uni ue identifiers for the any row in a table. They are internally used in the construction of inde+es. -ownum is the se uential number of rows in the result set object.

Q: What is the fastest query method for a table?


Ans: 4y rowid

Q: What is the difference of a LEFT JOIN and an INNER JOIN statement?


Ans: A "E6T 1O'/ will ta(e A"" values from the first declared table and matching values from the second declared table based on the column the join has been declared on. An '//E- 1O'/ will ta(e only matching values from both tables

Q: How can I avoid a divide by zero error?


Ans: .se the 0E#O0E function. This function is absolutely brilliant and functions li(e a #ASE statement, and can be used to return different columns based on the values of others.

Q: Is view updatable?
Ans: Only if the view is a sim%le hori5ontal slice through a single table.

Q: What is Dual ?
Ans: The 0.A" table is a table with a single row and a single column used where a table is syntactically re uired.

Q: What is the difference between CHAR and VARCHAR ?


Ans: #*A- is fi+ed length character ty%e at storage level, and that VA-#*A- will be variable length.

Q: Do we use commit in triggers.


Ans: /o

Q: How will the fetch the last inserted record in any table ?
Ans: select column 2, column 3.... from where rowid F !select ma+!rowid$ from table$I

Q: What are constraints and its types?


Ans: 'ntegrity #onstraint = An integrity constraint is a declarative way to define a business rule for a column of a table. An integrity constraint is a statement about a table,s data that is always true. Ty%es of integrity constraints = The following integrity constraints are su%%orted by O-A#"E= 2. !T *$$ : disallows nulls !em%ty entries$ in a table,s column 3. * '+*E : disallows du%licate values in a column or set of columns J. ),'MA,- .E- : disallows du%licate values and nulls in a column or set of columns K. /!,E'0 .E- : re uires each value in a column or set of columns match a value in a related table,s ./'>.E or P-'<A-D LED. 7. "1E". : disallows values that do not satisfy the logical e+%ression of the constraint

Q: What is Referential Integrity and Referential integrity constraint ?


Ans: ,eferential 'nte2rit& : -eferential integrity defines the relationshi%s among different columns and tables in a relational database. 'tMs called referential integrity because the values in one column or set of columns refer to or must match the values in a related column or set of columns. A referential inte2rit& constraint re uires that for each row of a table, the value in the

foreign (ey matches a value in a %arent (ey.

Q: What is groups by and having clause? Explain with example


Ans: :rou% by clause tells oracle to grou% rows based on distinct values that e+ists for s%ecified columns. The grou% by clause creates a data set , containing several sets of records grou%ed together based on condition. 1avin2 "lause: *aving clause can be used with :-O.P 4D clause. *aving im%oses a condition on the grou% by clause which further filters the grou% created by the :-O.P 4D clause. Select ename,em%no 6rom Em%l :rou% by em%no having em%no G 28I

Q: What are LOCKS? What are types of different types of Lock?


Ans: "oc(s are mechanisms intended to %revent destructive interaction between users accessing O-A#"E data. O-A#"E uses loc(s to control concurrent access to data. "oc(s are used to achieve two im%ortant database goals = #onsistency = Ensures that the data a user is viewing or changing is not changed !by other users$ until the user is finished with the data. 'ntegrity = Ensures that the database,s data and structures reflect all changes made to them in the correct se uence. Ty%es of "oc(s = 2. Data $oc3s 4DM$5 3. Dictionar& $oc3s 4DD$5 J. 'nternal $oc3s and $atches K. Distributed $oc3s 7. )arallel "ache Mana2e%ent $oc3s Data $oc3s : -ow "evel and Table "evel -ow "evel = E+clusive "oc(s Table "evel 2. -ow Share Table "oc(s !-S$ 3. -ow E+clusive Table "oc(s !-9$ J. Share Table "oc(s !S$ K. Share -ow E+clusive Table "oc(s !S-9$ 7. E+clusive Table "oc(s !9$ Dictionar& $oc3s : 2. E+clusive 00" "oc(s 3. Share 00" "oc(s J. 4rea(able Parse "oc(s -estrictiveness of "oc(s = 'n general, two levels of loc(ing can be used in a multi)user database= N E#clusive $oc3s : An e+clusive loc( %rohibits the sharing of the associated resource. The first transaction to e+clusively loc( a resource is the only transaction that can alter the resource until the e+clusive loc( is released. N Share "oc(s = A share loc( allows the associated resource to be shared, de%ending on the o%erations involved !e.g., several users can read the same data at the same time$. Several transactions can ac uire share loc(s on the same resource. Share loc(s allow a higher degree of data concurrency than e+clusive loc(s.

Q: Difference between unique key,primary key and foreign key ?


Ans: 6oreign (ey= A foreign (ey is one or more columns whose values are based on the %rimary or candidate (ey values from another table. .ni ue (ey can be nullI Primary (ey cannot be null.

Q: What are Advantages of TRUNCATE Command over DELETE/DROP TABLE Command ?


Ans: The T-./#ATE command %rovides a fast, efficient method for deleting all rows from a table or cluster. 2. A T,* "ATE statement does not generate any rollbac( information and it commits immediatelyI it is a 00" statement and cannot be rolled bac(. 3. A T,* "ATE statement does not affect any structures associated with the table being truncated !constraints and triggers$ or authori5ations !grants$. J. A T,* "ATE statement also s%ecifies whether s%ace currently allocated for the table is returned to the containing tables%ace after truncation. K. As a T,* "ATE statement deletes rows from a table !or clustered table$, triggers associated with the table are not fired. 7. Also, a T-./#ATE statement does not generate any audit information corres%onding to 0E"ETE statements if auditing is enabled. 'nstead, a single audit record is generated for the T-./#ATE statement being issued.

Q: What are steps involved in Execution of SQL statements?


Ans: STEPS '/ E9E#.T'O/ O6 S>" STATE<E/TS = 2. #reate a cursor 3. Parse the statement J. 0escribe -esults K. 0efining out%uts 7. 4ind any variables O. E+ecute the statement P. 6etch rows of a uery result

Q: What do you mean by Parsing?


Ans: )arsin2 : Parsing is the %rocess of= 2. translating a S>" statement, verifying it to be a valid statement 3. %erforming data dictionary loo(u%s to chec( table and column definitions J. ac uiring %arse loc(s on re uired objects so that their definitions do not change during the statement,s %arsing K. chec(ing %rivileges to access referenced schema objects 7. determining the e+ecution %lan to be used when e+ecuting the statement O. loading it into a shared S>" area P. for distributed statements, routing all or %art of the statement to remote nodes that contain referenced data

Q: What is a HINT and what are types HINT?


Ans: *ints are suggestions that you give the o%timi5er for o%timi5ing a S>" statement. *ints allow you to ma(e decisions usually made by the o%timi5er. TDPES O6 *'/TS = A"";-OAS = The A"";-OAS hint e+%licitly chooses the cost)based a%%roach to o%timi5e a statement bloc( with a goal of best through%ut. 6'-ST;-OAS = The 6'-ST;-OAS hint e+%licitly chooses the cost)based a%%roach to o%timi5e a statement bloc( with a goal of best res%onse time. 6."" = The 6."" hint e+%licitly chooses a full table scan for the s%ecified table. -OA'0 = The -OA'0 hint e+%licitly chooses a table scan by -OA'0 for

the s%ecified table. #".STE- = The #".STE- hint e+%licitly chooses a cluster scan to access the s%ecified table. *AS* = The *AS* hint e+%licitly chooses a hash scan to access the s%ecified table. '/0E9 = The '/0E9 hint e+%licitly chooses an inde+ scan for the s%ecified table. A/0;E>.A"= The A/0;E>.A" hint e+%licitly chooses an e+ecution %lan that uses an access %ath that merges the scans on several single)column inde+es. !Dou can s%ecify multi%le inde+es through this hint$ '/0E9;AS#= The '/0E9;AS# hint e+%licitly chooses an inde+ scan for the s%ecified table. 'f the statement uses an inde+ range scan, O-A#"E scans the inde+ entries in ascending order of their inde+ed values. '/0E9;0ES#= The '/0E9;0ES# hint e+%licitly chooses an inde+ scan for the s%ecified table. 'f the statement uses an inde+ range scan, O-A#"E scans the inde+ entries in descending order of their inde+ed values. O-0E-E0 = The O-0E-E0 hint causes O-A#"E to join tables in the order in which they a%%ear in the 6-O< clause. .SE;/" = The .SE;/" hint causes O-A#"E to join each s%ecified table to another row source with a nested loo%s join using the s%ecified table as the inner table. .SE;<E-:E = The .SE;<E-:E hint causes O-A#"E to join each s%ecified table with another row source with a sort)merge join.

Q: What do u mean by EXCEPTION_INIT Pragma ?


Ans: E6"E)T'! 7' 'T )ra2%a : To handle unnamed internal e+ce%tions, you must use the OT*E-S handler or the %ragma E9#EPT'O/;'/'T. A Q%ragmaQ is a com%iler directive, which can be thought of as a %arenthetical remar( to the com%iler. Pragmas !also called Q%seudoinstructionsQ$ are %rocessed at com%ile time, not at run time. They do not affect the meaning of a %rogramI they sim%ly convey information to the com%iler. The %redefined %ragma E9#EPT'O/;'/'T tells the P"&S>" com%iler to associate an e+ce%tion name with an Oracle error number. That allows you to refer to any internal e+ce%tion by name and to write a s%ecific handler for it. Dou code the %ragma E9#EPT'O/;'/'T in the declarative %art of a P"&S>" bloc(, sub%rogram, or %ac(age using the synta+ P-A:<A E9#EPT'O/;'/'T!e+ce%tion;name, Oracle;error;number$I where Qe+ce%tion;nameQ is the name of a %reviously declared e+ce%tion. 6or internal e+ce%tions, S>"#O0E returns the number of the associated Oracle error. The number that S>"#O0E returns is negative unless the Oracle error is Qno data found,Q in which case S>"#O0E returns R288. S>"E--< returns the message associated with the Oracle error that occurred. The message begins with the Oracle error code. 6or user)defined e+ce%tions, S>"#O0E returns R2 and S>"E--< returns the message S.ser)0efined E+ce%tionT unless you used the %ragma E9#EPT'O/;'/'T to associate the e+ce%tion name with an Oracle error number, in which case S>"#O0E returns that error number and S>"E--< returns the corres%onding error message. The ma+imum length of an Oracle error message is 723 characters including the error code, nested messages, and message inserts such as table and column names.

Q: What do u mean by JSP query?


Ans: JS) +uer& : The 1SP >uery is a standard uery for number to words conversion, used es%ecially for converting amount in number into e uivalent amount in words. The uery is as follows = Select to;char ! to;date ! UEnoM, U1M $, U1SPM $ words from dualI 6or eg = Select to;char ! to;date ! ,3JVKV,,,j, $, ,1SP, $ QwordsQ from dualI The value that can %ass to Eno cannot e+ceed P digits.

Q: Describe Oracle databases physical and logical structure ?


Ans: Physical= 0ata files, -edo "og files, #ontrol file. "ogical = Tables, Views, Tables%aces, etc.

Q: What is Check Constraints and with check options and Default Specification?
Ans: #*E#L 'ntegrity #onstraints= A #*E#L integrity constraint on a column or a set of columns re uires that a s%ecified condition be true or un(nown !ie. not false$ for every row of the table. 'f a 0<" statement is issued so that the condition of the #*E#L constraint evaluates to false, the statement is rolled bac(. Aith chec( O%tion= Aith #hec( o%tion restricts inserts and u%dates %erformed through the view to %revent them from creating rows that the view cannot itself select .based on where clause of the create view statement. 6or eg= #reate or re%lace view Aomen As select name from Em%loyee Ahere Se+F U6emaleM Aith #hec( O%tionI 0efault S%ecification 't su%%lies a default value if column value is not s%ecified on '/SE-T 't can contain literals !constants$ and S>" functions, .SE-, SDS0ATE, se uence 't cannot include references to any columns.

Q: What is the maximum no. of columns a table can have ?


Ans: 37K!Oracle$

Q: Can a trigger written for a view ?


Ans: /o

Q: Consider a sequence whose currval is 1 and gets incremented by 1 by using the nextval reference we get the next number 2. Suppose at this point we issue an rollback and again issue a nextval. What will the output be ?
Ans: J

Q: Can you create index on view ?


Ans: /o

Q: What is the difference between alias and synonym ?


Ans: Alias is tem%orary and used with one uery. Synonym is %ermanent and not used as alias.

Q: Whats the length of SQL integer ?


Ans: J3 bit length

Q: What is tkprof and how is it used?


Ans: The t(%rof tool is a tuning tool used to determine c%u and e+ecution times for S>" statements. Dou use it by first setting timed;statistics to true in the initiali5ation file and then turning on tracing for either the entire database via the s l;trace %arameter or for the session using the A"TE- SESS'O/ command. Once the trace file is generated you run the t(%rof tool against the trace file and then loo( at the out%ut from the t(%rof tool . This can also be used to generate e+%lain %lan out%ut.

Q: What is explain plan and how is it used?


Ans: The E9P"A'/ P"A/ command is a tool to tune S>" statements. To use it you must have an e+%lain;table generated in the user you are running the e+%lain %lan for. This is created using the utl+%lan.s l scri%t. Once the e+%lain %lan table e+ists you run the e+%lain %lan command giving as its argument the S>" statement to be e+%lained. The e+%lain;%lan table is then ueried to see the e+ecution %lan of the statement. E+%lain %lans can also be run using t(%rof.

Q: What is The Dynamic Performance Tables?


Ans: Throughout its o%eration, O-A#"E maintains a set of QvirtualQ tables that record current database activity. These tables are called 0ynamic %erformance tables. 4ecause dynamic %erformance tables are not true tables, they should not be accessed by most users. *owever, database administrators can uery these tables and can create views on the tables and grant access to those views to other users. The dynamic %erformance tables are owned by SDS and their names all begin with V;W. Views are created on these tables, and then synonyms are created for the views. The synonym names begin with VW.

Q: What is Savepoint ?
Ans: Save%oints are intermediate mar(ers that can be declared in long transactions that contain many S>" statements. 4y using save%oints, you can arbitrarily mar( your wor( at any %oint within a long transaction. This allows you the o%tion of later rolling bac( all wor( %erformed from the current %oint in the transaction to a declared save%oint within the transaction.

Q: What is Deadlocks?
Ans: A deadloc( is a situation that can occur in multi)user systems that causes some number of transactions to be unable to continue wor(. A deadloc( can occur when two or

more users are waiting for data loc(ed by each other. 't ty%ically ha%%ens when each of two or more users are waiting to access a resource that another user has already loc(ed. This creates a deadloc( situation because each user is waiting for resources held by the other user. Eg Transaction 2 Time Point Transaction 3 .P0ATE em% 2 .P0ATE em% SET sal F salB2.2 SET sal F 2JK3 A*E-E em%no F 2888I A*E-E em%no F 3888I .P0ATE em% 3 .P0ATE em% SET sal F salB2.2 SET sal F 2JK3 A*E-E em%no F 3888I A*E-E em%no F 2888I O-A)888O8 J deadloc( detected while waiting for resource

Q: What is Privilege ?
Ans: A %rivilege is a right to e+ecute a %articular ty%e of S>" statement or to access another user,s object. Ty%es of %rivileges = N system %rivileges N object %rivileges System Privileges = System %rivileges allow users to %erform a %articular systemwide action, or to %erform a %articular action on a %articular ty%e of object. E.g. #reate Tables%ace, 0elete the row of any table, etc. Object Privileges = Object %rivileges allow users to %erform a %articular action on a s%ecific object. E.g. delete row of s%ecific table, etc. -oles = -oles are named grou%s of related %rivileges that are granted to users or other roles. Advantages of -oles = 2. reduced granting of %rivileges 3. dynamic %rivilege management !#hanging of %rivileges$ J. selective availability of %rivileges !Enalbling&0isabling roles$ K. a%%lication awareness !Enalbling&0isabling of roles by a%%lication$

Q: What is Two Phase Commit ?


Ans: Two Phase #ommit is a mechanism wherein O-A#"E automatically controls and monitors the commit or rollbac( of a distributed transaction and maintains the integrity of the global database. The Phases of the Two)Phase #ommit <echanism = N Pre%are %hase = The global co)ordinator !initiating node$ as(s %artici%ants to %re%are !to %romise to commit or rollbac( the transaction, even if there is a failure$. N #ommit %hase = 'f all %artici%ants res%ond to the co)ordinator that they are %re%ared, the co)ordinator as(s all nodes to commit the transactionI if all %artici%ants cannot %re%are, the co)ordinator as(s all nodes to roll bac( the transaction.

Q: Explain about snapshots in detail?


Ans: Sna%shots are read)only co%ies of a master table !or multi%le tables$ located on a remote node. A sna%shot can be ueried, but not u%datedI only the master table can be u%dated. A sna%shot is %eriodically refreshed to reflect changes made to the master table. A sna%shot is a full co%y of a table or a subset of a table that reflects a recent state of the master table. A sna%shot is defined by a distributed uery that references one or more master tables, view, or other sna%shots. Sim%le vs. #om%le+ Sna%shots = Each row in a sim%le sna%shot is based on a single row in a single remote table. Therefore, a sim%le sna%shot,s defining uery has no :-O.P 4D or #O//E#T 4D clauses, or sub ueries, joins, or set o%erations. 'f a sna%shot,s defining uery contains any of these clauses or o%erations, it is referred to as a com%le+ sna%shot. 'nternals of Sna%shot #reation= Ahen a sna%shot is created, several o%erations are %erformed internally by O-A#"E= N O-A#"E !at the sna%shot node$ creates a table to store the rows retrieved by the sna%shot,s defining ueryI this is the sna%shot,s base table. N O-A#"E creates a read)only view on the S/APW table !base table$ for ueries issued against the sna%shot. N O-A#"E creates

a second local view on the remote master table. 't uses this view when it refreshes the sna%shot. N Additionally, if the sna%shot is a sim%le sna%shot, O-A#"E creates an inde+ on the S/APW table. All of these internal objects are created in the schema of the sna%shot. 0o not alter, change data in, or delete these objects manually.

Q: What is Ref Cursor?


Ans: A -E6 #.-SO- is basically a data ty%e. A variable created based on such a data ty%e is generally called a cursor variable. A cursor variable can be associated with different ueries at run)time. The %rimary advantage of using cursor variables is their ca%ability to %ass result sets between sub %rograms !li(e stored %rocedures, functions, %ac(ages etc.$.

Q: What is row chaining, how does it happen?


Ans: -ow chaining occurs when a VA-#*A-3 value is u%dated and the length of the new value is longer than the old value and wonMt fit in the remaining bloc( s%ace. This results in the row chaining to another bloc(. 't can be reduced by setting the storage %arameters on the table to a%%ro%riate values. 't can be corrected by e+%ort and im%ort of the effected table.

Q: Describe hit ratio as it pertains to the database buffers. What is the difference between instantaneous and cumulative hit ratio and which should be used for tuning?
Ans: The hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re)read a data value from the dis(s. A value greater than H8)V8@ is good, less could indicate %roblems. 'f you sim%ly ta(e the ratio of e+isting %arameters this will be a cumulative value since the database started. 'f you do a com%arison between %airs of readings based on some arbitrary time s%an, this is the instantaneous ratio for that time s%an. An instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over.

Q: What is a Cartesian product?


Ans: A #artesian %roduct is the result of an unrestricted join of two or more tables. The result set of a three table #artesian %roduct will have + B y B 5 number of rows where +, y, 5 corres%ond to the number of rows in each table involved in the join.

Q: What is a mutating table error and how can you get around it?
Ans: This ha%%ens with triggers. 't occurs because the trigger is trying to u%date a row it is currently using. The usual fi+ involves either use of views or tem%orary tables so the database is selecting from one while u%dating the other.

Q: What are SQLCODE and SQLERRM and why are they important for PL/SQL developers?
Ans: S>"#O0E returns the value of the error number for the last error encountered. The S>"E--< returns the actual error message for the last error encountered. They can be used in e+ce%tion handling to re%ort, or, store in an error log table, the error that occurred in the code. These are es%ecially useful for the A*E/ OT*E-S e+ce%tion.

Q: What are Transactional Triggers ? Give the uses of Transational Trigger ?


Ans: Transactional Triggers fire in res%onse to transaction %rocessing events. These events re%resent %oints during a%%lication %rocessing at which Oracle 6orms needs to interact with the data source. E+am%les of such events include u%dating records, rolling bac( to save%oints, and committing transactions. 4y default, Oracle 6orms assumes that the data source is an O-A#"E database, and issues the a%%ro%riate S>" statements to o%timi5e transaction %rocessing accordingly. *owever, by defining transactional triggers and user e+its, you can build a form to interact with virtually any data source, including even non)relational databases and flat files. #alling .ser E+its Ahen you define transactional triggers to interact with a non)O-A#"E data source, you will usually include a call to a user e+it in the a%%ro%riate triggers. The code in your user e+it interacts with the non)O-A#"E data source. Once the user e+it has %erformed the a%%ro%riate function !as indicated by the trigger from which it was called$, it returns control to Oracle 6orms for subse uent %rocessing. 6or e+am%le, a user e+it called from an On)6etch trigger might be res%onsible for retrieving the a%%ro%riate number of records from the non)O-A#"E data source. Once the records are retrieved, Oracle 6orms ta(es over the dis%lay and management of those records in the form interface, just as it would if the records had been fetched from an O-A#"E database. .ses for Transactional Triggers X Transactional triggers, e+ce%t for the commit triggers, are %rimarily intended to access certain data sources other than Oracle. X The logon and logoff transactional triggers can also be used with Oracle databases to change connections at run time.

Q: What is Autonomous transaction ? Where do we use it?


Ans: 'n Oracle,s database %roducts, an autonomous transaction is an inde%endent transaction that is initiated by another transaction. 't must contain at least one Structured >uery "anguage !S>"$ statement. Autonomous transactions allow a single transaction to be subdivided into multi%le commit&rollbac( transactions, each of which will be trac(ed for auditing %ur%oses. Ahen an autonomous transaction is called, the original transaction !calling transaction$ is tem%orarily sus%ended. The autonomous transaction must commit or roll bac( before it returns control to the calling transaction. Once changes have been made by an autonomous transaction, those changes are visible to other transactions in the database. Autonomous transactions can be nested. That is, an autonomous transaction can o%erate as a calling transaction, initiali5ing other autonomous transactions within itself.

Q: What is a package, procedure and function?


Ans: Pac(age = A %ac(age is a grou% of related %rogram objects stored together as a unit

in the database. A %ac(age is an enca%sulated collection of related %rogram objects stored together in the database. Program objects are= %rocedures, functions, variables, constants, cursors, e+ce%tions. Procedure&6unction = A %rocedure or function is a set of S>" and P"&S>" statements grou%ed together as an e+ecutable unit to %erform a s%ecific tas(. The main difference between a %rocedure and function is functions return a single variable by value whereas %rocedures do not return any variable by value. -ather they return multi%le variables by %assing variables by reference through their O.T %arameter.

Q: What do u mean by overloading?


Ans: 6unction Overloading = Pac(ages allow you to overload %rocedures or functions. Overloading a %rocedure means creating multi%le %rocedures with the same name in the same %ac(age, each ta(ing arguments of different number or dataty%e.

Q: What are the constructs of a procedure, function or a package ?


Ans: The constructs of a %rocedure, function or a %ac(age are = N variables and constants N cursors N e+ce%tions

Q: What are cascading triggers? What is the maximum no of cascading triggers at a time?
Ans: Ahen a statement in a trigger body causes another trigger to be fired, the triggers are said to be cascading. <a+ F J3

Q: What is the significance of the & and && operators in PL/SQL ?


Ans: The E o%erator means that the P" S>" bloc( re uires user in%ut for a variable. The EE o%erator means that the value of this variable should be the same as in%utted by the user %reviously for this same variable.

Q: If all the values from a cursor have been fetched and another fetch is issued, the output will be?
Ans: "ast -ecord

Q: What is a forward declaration ? What is its use ?


Ans: P"&S>" re uires that you declare an identifier before using it. Therefore, you must declare a sub%rogram before calling it. This declaration at the start of a sub%rogram is called forward declaration. A forward declaration consists of a sub%rogram s%ecification terminated by a semicolon.

Q: Any three PL/SQL Exceptions?


Ans: Too;many;rows, /o;0ata;6ound, Value;Error, Yero;Error, Others

Q: Describe the use of %ROWTYPE and %TYPE in PL/SQL


Ans: @-OATDPE allows you to associate a variable with an entire table row. The @TDPE associates a variable with a single column ty%e.

Q: How can you call a PL/SQL procedure from SQL?


Ans: 4y use of the E9E#.TE !short form E9E#$ command.

Q: What are the various types of Exceptions ?


Ans: .ser defined and Predefined E+ce%tions.

Q: What is RAISE_APPLICATION_ERROR ?
Ans: 04<S;STA/0A-0 %rovides a %rocedure named raise;a%%lication;error, which lets you issue user)defined error messages. That way, you can re%ort errors to an a%%lication and avoid returning unhandled e+ce%tions. The calling synta+ is = raise;a%%lication;error!error;number, error;message$I where error;number is a negative integer in the range )38888...)38VVV and error;message is a character string u% to 38KH bytes in length. An a%%lication can call raise;a%%lication;error only from an e+ecuting stored sub%rogram. Ahen called, raise;a%%lication;error ends the sub%rogram, rolls bac( any database changes it made, and returns a user)defined error number and message to the a%%lication. The error number and message can be tra%%ed li(e any O-A#"E error. The calling a%%lication gets a P"&S>" e+ce%tion, which it can %rocess using the error) re%orting functions S>"#O0E and S>"E--< in an OT*E-S handler. N The statement -aise;A%%lication;Error can be called either from a %rocedure body or from an e+ce%tion handler. N 'rres%ective of whether an error occurred or not, a raise;a%%lication;error command always raises an e+ce%tion in the calling %rogram !eg a forms trigger$. 'f an e+ce%tion handler is not written in that forms trigger, then a forms error occurs.

You might also like