Вы находитесь на странице: 1из 29

Doc5 Q. What is a Join?

A join is a query that combines rows from two or more tables, views, or materialized views ("snapshots"). Oracle performs a join whenever multiple tables appear in the queries !O" clause. #he query$s select list can select any columns from any of these tables. %f any two of these tables have a column name in common, you must qualify all references to these columns throu&hout the query with table names to avoid ambi&uity. Q. What are join conditions? "ost join queries contain '()!) clause conditions that compare two columns, each from a different table. *uch a condition is called a join condition. #o e+ecute a join, Oracle combines pairs of rows, each containin& one row from each table, for which the join condition evaluates to #!,). #he columns in the join conditions need not also appear in the select list. Q. What is an equijoin? An equijoin is a join with a join condition containin& an equality operator. An equijoin combines rows that have equivalent values for the specified columns. )&*elect ename, job, dept.deptno, dname rom emp, dept 'here emp.deptno = dept.deptno. Q. What are self joins? A self join is a join of a table to itself. #his table appears twice in the !O" clause and is followed by table aliases that qualify column names in the join condition. )&*)/)0# e.ename 11 2 wor3s for 2 11 e4.name 5)mployees and their "ana&ers6 !O" emp e7, emp e4 '()!) e7.m&r 8 e4.empno. ENAME $%A&E &0N" !esult- 9/A:) wor3s for :%;< Q. What is an !uter Join? An outer join e+tends the result of a simple join. An outer join returns all rows that satisfy the join condition and those rows from one table for which no rows from the other satisfy the join condition. *uch rows are not returned by a simple join. #o write a query that performs an outer join of tables A and 9 and returns all rows from A, apply the outer join operator (=) to all columns of 9 in the join condition. or all rows in A that have no matchin& rows in 9, Oracle returns null for any select list e+pressions containin& columns of 9. Outer join queries are subject to the followin& rules and restrictionsEM N! '()*5 +,-./ M"# +,-./ ((**+

Page 1 of 29

#he (=) operator can appear only in the '()!) clause or, in the conte+t of left correlation (that is, when specifyin& the #A9/) clause) in the !O" clause, and can be applied only to a column of a table or view. %f A and 9 are joined by multiple join conditions, you must use the (=) operator in all of these conditions. %f you do not, Oracle will return only the rows resultin& from a simple join, but without a warnin& or error to advise you that you do not have the results of an outer join. #he (=) operator can be applied only to a column, not to an arbitrary e+pression. (owever, an arbitrary e+pression can contain a column mar3ed with the (=) operator. A condition containin& the (=) operator cannot be combined with another condition usin& the O! lo&ical operator. A condition cannot use the %; comparison operator to compare a column mar3ed with the (=) operator with an e+pression. A condition cannot compare any column mar3ed with the (=) operator with a subquery. %f the '()!) clause contains a condition that compares a column from table 9 with a constant, the (=) operator must be applied to the column so that Oracle returns the rows from table A for which it has &enerated ;,//s for this column. Otherwise Oracle will return only the results of a simple join. %n a query that performs outer joins of more than two pairs of tables, a sin&le table can be the null>&enerated table for only one other table. or this reason, you cannot apply the (=) operator to columns of 9 in the join condition for A and 9 and the join condition for 9 and 0.

1et !perators2 3N0!N 4A%%56 0N7E#1E876 M0N31


*et operators combine the results of two component queries into a sin&le result. ?ueries containin& set operators are called compound queries. #he number and datatypes of the columns selected by each component query must be the same, but the column len&ths can be different. %f you combine more than two queries with set operators, Oracle evaluates adjacent queries from left to ri&ht. @ou can use parentheses to specify a different order of evaluation. !estrictions #hese set operators are not valid on columns of type 9/O9, 0/O9, 9 %/), varray, or nested table. #he ,;%O;, %;#)!*)0#, and "%;,* operators are not valid on /O;< columns. #o reference a column, you must use an alias to name the column. @ou cannot also specify the forAupdateAclause with these set operators. @ou cannot specify the orderAbyAclause in the subquery of these operators.

All set operators have equal precedence. %f a *?/ statement contains multiple set operators, Oracle evaluates them from the left to ri&ht if no parentheses e+plicitly specify another order.

Page 2 of 29

#he correspondin& e+pressions in the select lists of the component queries of a compound query must match in number and datatype. %f component queries select character data, the datatype of the return values are determined as follows %f both queries select values of datatype 0(A!, the returned values have datatype 0(A!. %f either or both of the queries select values of datatype BA!0(A!4, the returned values have datatype BA!0(A!4. Q. What is a 3N0!N? #he ,;%O; operator eliminates duplicate records from the selected rows. 'e must match datatype (usin& the #OACA#) and #OA;,"9)! functions) when columns do not e+ist in one or the other table. Q. What is 3N0!N A%%? #he ,;%O; A// operator does not eliminate duplicate selected rows. Note2 #he ,;%O; operator returns only distinct rows that appear in either result, while the ,;%O; A// operator returns all rows. Q. What is an 0N7E#1E87? #he %;#)!*)0# operator returns only those rows returned by both queries. %t shows only the distinct values from the rows returned by both queries. Q. What is M0N31? #he "%;,* operator returns only rows returned by the first query but not by the second. %t also eliminates the duplicates from the first query.

Note: For compound queries (containing set operators UNION, INTER E!T, "INU , or UNION #$$%, t&e OR'ER () c*ause must use positions, rat&er t&an e+p*icit e+pressions, #*so, t&e OR'ER () c*ause can appear on*- in t&e *ast component quer-, T&e OR'ER () c*ause orders a** ro.s returned /- t&e entire compound quer-,

Q. 9o: man; t;pes of 1ql 1tatements are there in !racle? #here are basically D types of sql statements. #hey area) Cata Cefinition /an&ua&e (CC/) #he CC/ statements define and maintain objects and drop objects. b) Cata "anipulation /an&ua&e (C"/) #he C"/ statements manipulate database data. c) #ransaction 0ontrol *tatements "ana&e chan&e by C"/ d) *ession 0ontrol ,sed to control the properties of current session enablin& and disablin& roles and chan&in&. ).&. Alter *tatements, *et !ole

Page 0 of 29

e) *ystem 0ontrol *tatements 0han&e Eroperties of Oracle %nstance. ).&. Alter *ystem f) )mbedded *ql %ncorporate CC/, C"/ and #0* in Ero&rammin& /an&ua&e. ).&. ,sin& the *ql *tatements in lan&ua&es such as F0F, Open, etch, e+ecute and close Q< What is a 7ransaction in !racle? A transaction is a /o&ical unit of wor3 that compromises one or more *?/ *tatements e+ecuted by a sin&le ,ser. Accordin& to A;*%, a transaction be&ins with first e+ecutable statement and ends when it is e+plicitly committed or rolled bac3. A transaction is an atomic unit. Q. What are some of the &e; Words 3sed in !racle? *ome of the :ey words that are used in Oracle area) 8ommittin=- A transaction is said to be committed when the transaction ma3es permanent chan&es resultin& from the *?/ statements. b) #oll>ac?- A transaction that retracts any of the chan&es resultin& from *?/ statements in #ransaction. c) 1a@e oint- or lon& transactions that contain many *?/ statements, intermediate mar3ers or savepoints are declared. *avepoints can be used to divide a transaction into smaller points. 'e can declare intermediate mar3ers called savepoints within the conte+t of a transaction. *avepoints divide a lon& transaction into smaller parts. ,sin& savepoints, we can arbitrarily mar3 our wor3 at any point within a lon& transaction. 'e then have the option later of rollin& bac3 wor3 performed before the current point in the transaction but after a declared savepoint within the transaction. or e+ample, we can use savepoints throu&hout a lon& comple+ series of updates so that if we ma3e an error, we do not need to resubmit every statement. d) #ollin= Aor:ard- Erocess of applyin& redo lo& durin& recovery is called rollin& forward. e) 0ursor- A cursor is a handle (name or a pointer) for the memory associated with a specific statement. A cursor is basically an area allocated by Oracle for e+ecutin& the *ql *tatement. Oracle uses an implicit cursor statement for *in&le row query and ,ses )+plicit cursor for a multi row query. f) 1;stem "lo>al Area B1"A< - #he *<A is a shared memory re&ion allocated by the Oracle that contains Cata and control information for one Oracle %nstance. %t consists of Catabase 9uffer 0ache and !edo lo& 9uffer. (:E%# %nfotech, Eune) &) ro=ram "lo>al Area B "A< - #he E<A is a memory buffer that contains data and control information for server process. &) Data>ase $uffer 8ache- Catabase 9uffer of *<A stores the most recently used bloc3s of database data. #he set of database buffers in an instance is called Catabase 9uffer 0ache. h) #edo lo= $uffer- !edo lo& 9uffer of *<A stores all the redo lo& entries.

Page 1 of 29

i) #edo %o= Ailes- !edo lo& files are set of files that protect altered database data in memory that has not been written to Cata iles. #hey are basically used for bac3up when a database crashes. j) rocess- A Erocess is a Fthread of controlF or mechanism in Operatin& *ystem that e+ecutes series of steps. Q. What are rocedure6 functions and ac?a=es? Erocedures and functions consist of set of E/G*?/ statements that are &rouped to&ether as a unit to solve a specific problem or perform set of related tas3s. Erocedures do not return values while unctions return one Balue. Eac3a&es- Eac3a&es provide a method of encapsulatin& and storin& related procedures, functions, variables and other Eac3a&e 0ontents Q. What are Data>ase 7ri==ers and 1tored rocedures? Data>ase 7ri==ers- Catabase #ri&&ers are Erocedures that are automatically e+ecuted as a result of insert in, update to, or delete from table. Catabase tri&&ers have the values old and new to denote the old value in the table before it is deleted and the new indicated the new value that will be used. C# is useful for implementin& comple+ business rules which cannot be enforced usin& the inte&rity rules. 'e can have the tri&&er as 9efore tri&&er or After #ri&&er and at *tatement or !ow level. e.&-- operations insert, update ,delete H before ,after HI4 A total of D combinations At statement level(once for the tri&&er) or row level( for every e+ecution ) D I 4 A total of 74. #hus a total of 74 combinations are there and the restriction of usa&e of 74 tri&&ers has been lifted from Oracle J.H Onwards. 1tored rocedures- *tored Erocedures are Erocedures that are stored in 0ompiled form in the database. #he advanta&e of usin& the stored procedures is that many users can use the same procedure in compiled and ready to use format. Q. 9o: man; 0nte=rit; #ules are there and :hat are the;? #here are #hree %nte&rity !ules. #hey are as followsa) )ntity %nte&rity !ule- #he )ntity %nte&rity !ule enforces that the Erimary 3ey cannot be ;ull b) orei&n :ey %nte&rity !ule- #he :%! denotes that the relationship between the forei&n 3ey and the primary 3ey has to be enforced. 'hen there is data in 0hild #ables the "aster tables cannot be deleted. c) 9usiness %nte&rity !ules- #he #hird %nte&rity rule is about the comple+ business processes which cannot be implemented by the above 4 rules. Q. What are the Carious Master and Detail #elationships? #he various "aster and Cetail !elationship are a) ;o %solated - #he "aster cannot be deleted when a child is e+istin& b) %solated - #he "aster can be deleted when the child is e+istin& c) 0ascadin& - #he child &ets deleted when the "aster is deleted.

Page 2 of 29

Q. What are the Carious $loc? 8oordination roperties? #he various 9loc3 0oordination Eroperties area) %mmediate Cefault *ettin&. #he Cetail records are shown when the "aster !ecord are shown. b) Ceferred with Auto ?uery Oracle orms defer fetchin& the detail records until the operator navi&ates to the detail bloc3. c) Ceferred with ;o Auto ?uery #he operator must navi&ate to the detail bloc3 and e+plicitly e+ecute a query Q. What are the Different !ptimiDation 7echniques? #he Barious Optimization techniques area) )+ecute Elan- we can see the plan of the query and chan&e it accordin&ly based on the inde+es b) OptimizerAhint- setAitemAproperty (FCept9loc3F,OE#%"%K)!A(%;#,F %!*#A!O'*F). *elect GI= irstA!ows IG Ceptno,Cname,/oc,!owid from dept where (Ceptno L 4M) c) OptimizeA*ql- 9y settin& the OptimizeA*ql 8 ;o, Oracle orms assi&ns a sin&le cursor for all *?/ statements. #his slow downs the processin& because for every time the *?/ must be parsed whenever they are e+ecuted. fNMrun module 8 myAfirstform userid 8 scottGti&er optimizeAsql 8 ;o d) OptimizeA#p9y settin& the OptimizeA#p8 ;o, Oracle orms assi&ns seperate cursor only for each query *)/)0# statement. All other *?/ statements reuse the cursor. fNMrun module 8 myAfirstform userid 8 scottGti&er optimizeA#p 8 ;o Q. 9o: do u implement the 0f statement in the 1elect 1tatement? 'e can implement the if statement in the select statement by usin& the Cecode statement. e.& select C)0OC) ()"EA0A#,F7F,F irstF,F4F,F*econd$, ;ull). Q. 9o: man; t;pes of EEceptions are there? #here are 4 types of e+ceptions. #hey area) *ystem )+ceptions e.&. 'hen noAdataAfound, 'hen tooAmanyArows b) ,ser Cefined )+ceptions e.&. "yAe+ception e+ception 'hen "yAe+ception then Q. What are the inline and the precompiler directi@es? #he inline and precompiler directives detect the values directly. Q. 9o: do ;ou use the same lo@ for ( columns?

Page 3 of 29

'e can use the same lov for 4 columns by passin& the return values in &lobal values and usin& the &lobal values in the code. Q. 9o: man; minimum =roups are required for a matriE report? #he minimum number of &roups in matri+ report is N. Q. What is the difference >et:een static and d;namic lo@? #he static lov contains the predetermined values while the dynamic lov contains values that come at run time. Q. What are the !! 1 concepts in !racle? Oracle does implement the OOE* concepts. #he best e+ample is the Eroperty 0lasses. 'e can cate&orize the properties by settin& the visual attributes and then attach the property classes for the objects. OOE* supports the concepts of objects and classes and we can consider the property classes as classes and the items as objects Q. What is the difference >et:een candidate ?e;6 unique ?e; and primar; ?e;? 0andidate 3eys are the columns in the table that could be the primary 3eys and the primary 3ey is the 3ey that has been selected to identify the rows. ,nique 3ey is also useful for identifyin& the distinct rows in the table. Q. What is concurrenc;? ?. 0oncurrency is allowin& simultaneous access of same data by different users. /oc3s useful for accessin& the database area) )+clusive #he e+clusive loc3 is useful for loc3in& the row when an insert, update or delete is bein& done. #his loc3 should not be applied when we do only select from the row. b) *hare loc3 'e can do the table as *hareA/oc3 and as many shareAloc3s can be put on the same resource. Q. What are ri@ile=es and "rants? Erivile&es are the ri&ht to e+ecute a particular type of *?/ statements. ).&. !i&ht to 0onnect, !i&ht to create, !i&ht to resource <rants are &iven to the objects so that the object mi&ht be accessed accordin&ly. #he &rant has to be &iven by the owner of the object. Q. What are 7a>le 1pace6 Data Ailes6 arameter Aile and 8ontrol Ailes? 7a>le 1pace- #he table space is useful for storin& the data in the database. 'hen a database is created two table spaces are created. a) *ystem #able space- #his data file stores all the tables related to the system and dba tables b) ,ser #able space- #his data file stores all the user related tables

Page 4 of 29

'e should have separate table spaces for storin& the tables and inde+es so that the access is fast. Data Ailes2 )very Oracle Cata 9ase has one or more physical data files. #hey store the data for the database. )very data file is associated with only one database. Once the Cata file is created the size cannot chan&e. #o increase the size of the database to store more data we have to add data file. arameter Ailes- Earameter file is needed to start an instance.A parameter file contains the list of instance confi&uration parameters. e.&. dbAbloc3Abuffers 8 MOO dbAname 8 O!AJ dbAdomain 8 u.s.acme lan& 8ontrol Ailes- 0ontrol files record the physical structure of the data files and redo lo& files #hey contain the Cb name, name and location of dbs, data files, redo lo& files and time stamp. Q. 1ome of the terms related to h;sical 1tora=e of the Data. #he finest level of &ranularity of the data base is the data bloc3s. Data $loc? EEtent 1e=ments - One Cata 9loc3 correspond to specific number of physical database space - )+tent is the number of specific number of conti&uous data bloc3s. - *et of )+tents allocated for )+tents. #here are three types of *e&ments.

a) Cata *e&ment- ;on 0lustered #able has data se&ment data of every table is stored in cluster data se&ment b) %nde+ *e&ment- )ach %nde+ has inde+ se&ment that stores data c) !oll 9ac3 *e&ment- #emporarily store FundoF information Q. What are the ct Aree and ct 3sed? Ect ree is used to denote the percenta&e of the free space that is to be left when creatin& a table. *imilarly Ect ,sed is used to denote the percenta&e of the used space that is to be used when creatin& a table ).&. Ectfree 4O, Ectused NO Q. What is #o: 8hainin=? #he data of a row in a table may not be able to fit the same data bloc3. Cata for row is stored in a chain of data bloc3s. Q. What is a ( hase 8ommit? #wo Ehase commit is used in distributed data base systems. #his is useful to maintain the inte&rity of the database so that all the users see the same values. %t contains C"/ statements or !emote Erocedural calls that reference a remote object. #here are basically 4 phases in a 4 phase commit. a) Erepare Ehase- <lobal coordinator as3s participants to prepare b) 0ommit Ehase- 0ommit all participants to coordinator to Erepared, !ead only or abort !eply

Page 5 of 29

A two>phase commit mechanism &uarantees that all database servers participatin& in a distributed transaction either all commit or all roll bac3 the statements in the transaction. A two> phase commit mechanism also protects implicit C"/ operations performed by inte&rity constraints, remote procedure calls, and tri&&ers. Q. What is the difference >et:een deletin= and truncatin= of ta>les? Celetin& a table will not remove the rows from the table but entry is there in the database dictionary and it can be retrieved 9ut truncatin& a table deletes it completely and it cannot be retrieved. Q. What are mutatin= ta>les? 'hen a table is in state of transition it is said to be mutatin&. ).&. %f a row has been deleted then the table is said to be mutatin& and no operations can be done on the table e+cept select. Q. What are 8odd #ules? 0odd !ules describe the ideal nature of a !C9"*. ;o !C9"* satisfies all the 74 codd rules and Oracle *atisfies 77 of the 74 rules and is the only !C9"* to satisfy the ma+imum number of rules. Q. What is NormaliDation? ;ormalization is the process of or&anizin& the tables to remove the redundancy. #here are mainly M ;ormalization rules. 7 ;ormal orm > A table is said to be in 7st ;ormal orm when the attributes are atomic 4 ;ormal orm > A table is said to be in 4nd ;ormal orm when all the candidate 3eys are dependant on the primary 3ey Hrd ;ormal orm > A table is said to be third ;ormal form when it is not dependant transitively Q. What is the Difference >et:een a post quer; and a pre quer;? A post query will fire for every row that is fetched but the pre query will fire only once. Q. 9o: can :e delete the duplicate ro:s in the ta>le? 'e can delete the duplicate rows in the table by usin& the !owid. Q. 8an 3 disa>le data>ase tri==er? 9o:? @es. 'ith respect to table A/#)! #A9/) #A9/) P C%*A9/) allAtri&&er Q Q. What are pseudocolumns? Name them? A pseudocolumn behaves li3e a table column, but is not actually stored in the table. @ou can select from pseudocolumns, but you cannot insert, update, or delete their values. #his section describes these pseudocolumnsI 0,!!BA/ I ;)R#BA/ I /)B)/ I !O'%C

Page 9 of 29

I !O';," Q. 9o: man; columns can ta>le ha@e? #he number of columns in a table can ran&e from 7 to 4MN. Q. 0s space acquired in >loc?s or eEtents? %n e+tents. Q. What is clustered indeE? %n an inde+ed cluster, rows are stored to&ether based on their cluster 3ey values. 0an not be applied for (A*(. Q. What are the datat;pes supported $; oracle B0N7E#NA%<? Barchar4, ;umber, 0har, "/*/A9)/. Q. What are attri>utes of cursor? S O,;C , S;O# O,;C , S%*OE);,S!O'0O,;# Q. 8an ;ou use select in A#!M clause of 1Q% select ? @es. Q. Descri>e the difference >et:een a procedure6 function and anon;mous plFsql >loc?. 0andidate should mention use of C)0/A!) statement, a function must return a value while a procedure doesn$t have to. Q. What is a mutatin= ta>le error and ho: can ;ou =et around it? #his happens with tri&&ers. %t occurs because the tri&&er is tryin& to modify a row it is currently usin&. #he usual fi+ involves either use of views or temporary tables so the database is selectin& from one while updatin& the other. Q. Descri>e the use of G#!W7H E and G7H E in %F1Q%. S!O'#@E) allows you to associate a variable with an entire table row. #he S#@E) associates a variable with a sin&le column type.

Q. What pac?a=es Bif an;< has !racle pro@ided for use >; de@elopers? Oracle provides the C9"*A series of pac3a&es. #here are many which developers should be aware of such as C9"*A*?/, C9"*AE%E), C9"*A#!A;*A0#%O;, C9"*A/O0:, C9"*AA/)!#, C9"*AO,#E,#, C9"*ATO9, C9"*A,#%/%#@, C9"*ACC/, ,#/A %/). %f they can mention a few of these and describe how they used them, even better. %f they include the *?/ routines provided by Oracle, &reat, but not really what was as3ed.

Page 16 of 29

Q. Descri>e the use of %F1Q% ta>les. E/G*?/ tables are scalar arrays that can be referenced by a binary inte&er. #hey can be used to hold values for use in later queries or calculations. %n Oracle U they will be able to be of the S!O'#@E) desi&nation, or !)0O!C. Q. When is a declare statement needed? #he C)0/A!) statement is used in E/G*?/ anonymous bloc3s such as with stand alone, non> stored E/G*?/ procedures. %t must come first in a E/G*?/ standalone file if it is used.

Q. 0n :hat order should a openFfetchFloop set of commands in a %F1Q% >loc? >e implemented if ;ou use the GN!7A!3ND cursor @aria>le in the eEit :hen statement? Wh;? OE); then )#0( then /OOE followed by the e+it when. %f not specified in this order will result in the final return bein& done twice because of the way the S;O# O,;C is handled by E/G*?/. Q. What are 1Q%8!DE and 1Q%E##M and :h; are the; important for %F1Q% de@elopers? *?/0OC) returns the value of the error number for the last error encountered. #he *?/)!!" returns the actual error messa&e for the last error encountered. #hey can be used in e+ception handlin& to report, or, store in an error lo& table, the error that occurred in the code. #hese are especially useful for the '(); O#()!* e+ception. Q. 9o: can ;ou find :ithin a %F1Q% >loc?6 if a cursor is open? ,se the S%*OE); cursor status variable. Q. 9o: can ;ou =enerate de>u==in= output from %F1Q%? ,se the C9"*AO,#E,# pac3a&e. Another possible method is to just use the *(O' )!!O! command, but this only shows errors. #he C9"*AO,#E,# pac3a&e can be used to show intermediate results from loops and the status of variables as the procedure is e+ecuted. #he new pac3a&e ,#/A %/) can also be used. Q. What are the t;pes of tri==ers? #here are 74 types of tri&&ers in E/G*?/ that consist of combinations of the 9) O!), A #)!, !O', #A9/), %;*)!#, ,ECA#), C)/)#) and A// 3ey words9) O!) A// !O' %;*)!# A #)! A// !O' %;*)!# 9) O!) %;*)!# A #)! %;*)!# etc. Q. 9o: can @aria>les >e passed to a 1Q% routine?

Page 11 of 29

9y use of the V or double VV symbol. or passin& in variables numbers can be used (V7, V4,...,VU) to pass the values after the command into the *?/E/,* session. #o be prompted for a specific variable, place the ampersanded variable in the code itself5select I from dbaAtables where owner8VownerAname.6 . ,se of double ampersands tells *?/E/,* to resubstitute the value for each subsequent use of the variable, a sin&le ampersand will cause a reprompt for the value unless an A00)E# statement is used to &et the value from the user. Q. Hou :ant to include a carria=e returnFlinefeed in ;our output from a 1Q% script6 ho: can ;ou do this? #he best method is to use the 0(!() function (0(!(7O) is a returnGlinefeed) and the concatenation function 5116. Another method, althou&h it is hard to document and isn$t always portable is to use the returnGlinefeed as a part of a quoted strin&. Q. 9o: can ;ou call a %F1Q% procedure from 1Q%? 9y use of the )R)0,#) (short form )R)0) command. @ou can also wrap the call in a 9)<%; );C bloc3 and treat it as an anonymous E/G*?/ bloc3. Q. 9o: do ;ou eEecute a host operatin= s;stem command from :ithin 1Q%? 9y use of the e+clamation point 5W6 (in ,;%R and some other O*) or the (O*# ((O) command. Q. Hou :ant to use 1Q% to >uild 1Q%6 :hat is this called and =i@e an eEample? #his is called dynamic *?/. An e+ample would beset lines XO pa&es O termout off feedbac3 off verify off spool dropAall.sql select 2drop user 211username11$ cascade.$ from dbaAusers where username not in (5*@*$,$*@*#)"$). spool off )ssentially you are loo3in& to see that they 3now to include a command (in this case C!OE ,*)!...0A*0AC).) and that you need to concatenate usin& the 211$ the values selected from the database. Q. What 1Q% lus command is used to format output from a select? #his is best done with the 0O/,"; command. Q. Hou :ant to =roup the follo:in= set of select returns6 :hat can ;ou =roup on? MaEBsumIofIcost<6 minBsumIofIcost<6 countBitemIno<6 itemIno #he only column that can be &rouped on is the 5itemAno6 column, the rest have a&&re&ate functions associated with them.

Page 12 of 29

Q. What special !racle feature allo:s ;ou to specif; ho: the cost >ased s;stem treats a 1Q% statement? #he 0O*# based system allows the use of (%;#s to control the optimizer path selection. %f they can &ive some e+ample hints such as %!*# !O'*, A// !O'*, ,*%;< %;C)R, *#A!, even better. Q. Hou :ant to determine the location of identical ro:s in a ta>le >efore attemptin= to place a unique indeE on the ta>le6 ho: can this >e done? Oracle tables always have one &uaranteed unique column, the rowid column. %f you use a minGma+ function a&ainst your rowid and then select a&ainst the proposed primary 3ey you can squeeze out the rowids of the duplicate rows pretty quic3. or e+ampleselect rowid from emp e where e.rowid L (select min(+.rowid) from emp + where +.empAno 8 e.empAno). %n the situation where multiple columns ma3e up the proposed 3ey, they must all be used in the where clause. Q. What is a 8artesian product? A 0artesian product is the result of an unrestricted join of two or more tables. #he result set of a three table 0artesian product will have + I y I z number of rows where +, y, z correspond to the number of rows in each table involved in the join. #his occurs if there are not at least n>7 joins where n is the number of tables in a *)/)0#. Q. Hou are joinin= a local and a remote ta>le6 the net:or? mana=er complains a>out the traffic in@ol@ed6 ho: can ;ou reduce the net:or? traffic? Eush the processin& of the remote data to the remote instance by usin& a view to pre>select the information for the join. #his will result in only the data required for the join bein& sent across. Q. What is the default orderin= of an !#DE# $H clause in a 1E%E87 statement? Ascendin& Q. What is t?prof and ho: is it used? #he t3prof tool is a tunin& tool used to determine cpu and e+ecution times for *?/ statements. @ou use it by first settin& timedAstatistics to true in the initialization file and then turnin& on tracin& for either the entire database via the sqlAtrace parameter or for the session usin& the A/#)! *)**%O; command. Once the trace file is &enerated you run the t3prof tool a&ainst the trace file and then loo3 at the output from the t3prof tool. #his can also be used to &enerate e+plain plan output. Q. What is eEplain plan and ho: is it used?

Page 10 of 29

#he )RE/A%; E/A; command is a tool to tune *?/ statements. #o use it you must have an e+plainAtable &enerated in the user you are runnin& the e+plain plan for. #his is created usin& the utl+plan.sql script. Once the e+plain plan table e+ists you run the e+plain plan command &ivin& as its ar&ument the *?/ statement to be e+plained. #he e+plainAplan table is then queried to see the e+ecution plan of the statement. )+plain plans can also be run usin& t3prof. Q. 9o: do ;ou set the num>er of lines on a pa=e of output? 7he :idth? #he *)# command in *?/E/,* is used to control the number of lines &enerated per pa&e and the width of those lines, for e+ample *)# EA<)*%K) DO /%;)*%K) UO will &enerate reports t&at are DO lines lon& with a line width of UO characters. #he EA<)*%K) and /%;)*%K) options can be shortened to EA<)* and /%;)*. Q. 9o: do ;ou pre@ent output from comin= to the screen? #he *)# option #)!"O,# controls output to the screen. *ettin& #)!"O,# O screen output. #his option can be shortened to #)!". turns off

Q. 9o: do ;ou pre@ent !racle from =i@in= ;ou informational messa=es durin= and after a 1Q% statement eEecution? #he *)# options ))C9A0: and B)!% @ can be set to O Q. 9o: do ;ou =enerate file output from 1Q%? 9y use of the *EOO/ command. Data Modeler2 Q. Descri>e third normal form? )+pected answer- *omethin& li3e- %n third normal form all attributes in an entity are related to the primary 3ey and only to the primary 3ey Q. 0s the follo:in= statement true or false? 'hy or why notY JAll relational data>ases must >e in third normal formK alse. 'hile H; is &ood for lo&ical desi&n most databases, if they have more than just a few tables, will not perform well usin& full H; . ,sually some entities will be denormalized in the lo&ical to physical transfer process. Q. What is an E#D? An )!C is an )ntity>!elationship>Cia&ram. %t is used to show the entities and relationships for a database lo&ical model. Q. Wh; are recursi@e relationships >ad? 9o: do ;ou resol@e them? .

Page 11 of 29

A recursive relationship (one where a table relates to itself) is bad when it is a hard relationship (i.e. neither side is a 5may6 both are 5must6) as this can result in it not bein& possible to put in a top or perhaps a bottom of the table (for e+ample in the )"E/O@)) table you couldn$t put in the E!)*%C);# of the company because he has no boss, or the junior janitor because he has no subordinates). #hese type of relationships are usually resolved by addin& a small intersection entity. Q. What does a hard oneLtoLone relationship mean Bone :here the relationship on >oth ends is JmustK<? #his means the two entities should probably be made into one entity. Q. 9o: should a man;LtoLman; relationship >e handled? 9y addin& an intersection entity table Q. What is an artificial Bderi@ed< primar; ?e;? When should an artificial Bor deri@ed< primar; ?e; >e used? A derived 3ey comes from a sequence. ,sually it is used when a concatenated 3ey becomes too cumbersome to use as a forei&n 3ey. Q. When should ;ou consider denormaliDation? 'henever performance analysis indicates it would be beneficial to do so without compromisin& data inte&rity. ?. 'hat is a *chemaY Associated with each database user is a schema. A schema is a collection of schema objects. *chema objects include tables, views, sequences, synonyms, inde+es, clusters, database lin3s, snapshots, procedures, functions, and pac3a&es. ?. 'hat do you mean by tableY #ables are the basic unit of data stora&e in an Oracle database. Cata is stored in rows and columns. A row is a collection of column information correspondin& to a sin&le record. ?. %s there an alternative of droppin& a column from a tableY %f yes, whatY Croppin& a column in a lar&e table ta3es a considerable amount of time. A quic3er alternative is to mar3 a column as unused with the *)# ,;,*)C clause of the A/#)! #A9/) statement. #his ma3es the column data unavailable, althou&h the data remains in each row of the table. After mar3in& a column as unused, you can add another column that has the same name to the table. #he unused column can then be dropped at a later time when you want to reclaim the space occupied by the column data. ?. 'hat is a rowidY #he rowid identifies each row piece by its location or address. Once assi&ned, a &iven row piece retains its rowid until the correspondin& row is deleted, or e+ported and imported usin& the )+port and %mport utilities.

Page 12 of 29

?. 'hat is a viewY (:E%# %nfotech, Eune) A view is a tailored presentation of the data contained in one or more tables or other views. A view ta3es the output of a query and treats it as a table. #herefore, a view can be thou&ht of as a stored query or a virtual table. ,nli3e a table, a view is not allocated any stora&e space, nor does a view actually contain data. !ather, a view is defined by a query that e+tracts or derives data from the tables that the view references. #hese tables are called base tables. 9ase tables can in turn be actual tables or can be views themselves (includin& snapshots). 9ecause a view is based on other objects, a view requires no stora&e other than stora&e for the definition of the view (the stored query) in the data dictionary. ?. 'hat are the advanta&es of havin& a viewY #he advanta&es of havin& a view are #o provide an additional level of table security by restrictin& access to a predetermined set of rows or columns of a table #o hide data comple+ity #o simplify statements for the user #o present the data in a different perspective from that of the base table #o isolate applications from chan&es in definitions of base tables #o save comple+ queries or e+ample, a query can perform e+tensive calculations with table information. 9y savin& this query as a view, you can perform the calculations each time the view is queried. ?. 'hat is a "aterialized BiewY ((oneywell, :E%# %nfotech, Eune) "aterialized views, also called snapshots, are schema objects that can be used to summarize, precompute, replicate, and distribute data. #hey are suitable in various computin& environments especially for data warehousin&. rom a physical desi&n point of view, "aterialized Biews resembles tables or partitioned tables and behave li3e inde+es. ?. 'hat is the si&nificance of "aterialized Biews in data warehousin&Y %n data warehouses, materialized views are used to precompute and store a&&re&ated data such as sums and avera&es. "aterialized views in these environments are typically referred to as summaries because they store summarized data. #hey can also be used to precompute joins with or without a&&re&ations. 0ost>based optimization can use materialized views to improve query performance by automatically reco&nizin& when a materialized view can and should be used to satisfy a request. #he optimizer transparently rewrites the request to use the materialized view. ?ueries are then directed to the materialized view and not to the underlyin& detail tables or views. Q. Differentiate >et:een Cie:s and MaterialiDed Cie:s? (:E%# %nfotech, Eune) Q. What is the major difference >et:een an indeE and MaterialiDed @ie:? ,nli3e inde+es, materialized views can be accessed directly usin& a *)/)0# statement. Q. What are the procedures for refreshin= MaterialiDed @ie:s?

Page 13 of 29

Oracle maintains the data in materialized views by refreshin& them after chan&es are made to their master tables. #he refresh method can bea) incremental (fast refresh) or b) complete or materialized views that use the fast refresh method, a materialized view lo& or direct loader lo& 3eeps a record of chan&es to the master tables. "aterialized views can be refreshed either on demand or at re&ular time intervals. Alternatively, materialized views in the same database as their master tables can be refreshed whenever a transaction commits its chan&es to the master tables. ?. 'hat are materialized view lo&sY A materialized view lo& is a schema object that records chan&es to a master table$s data so that a materialized view defined on the master table can be refreshed incrementally. Another name for materialized view lo& is snapshot lo&. )ach materialized view lo& is associated with a sin&le master table. #he materialized view lo& resides in the same database and schema as its master table. ?. 'hat is a synonymY A synonym is an alias for any table, view, snapshot, sequence, procedure, function, or pac3a&e. 9ecause a synonym is simply an alias, it requires no stora&e other than its definition in the data dictionary. ?. 'hat are the advanta&es of havin& synonymsY *ynonyms are often used for security and convenience. or e+ample, they can do the followin&7. "as3 the name and owner of an object 4. Erovide location transparency for remote objects of a distributed database H. *implify *?/ statements for database users Q. What are the ad@anta=es of ha@in= an indeE? !r What is an indeE? #he purpose of an inde+ is to provide pointers to the rows in a table that contain a &iven 3ey value. %n a re&ular inde+, this is achieved by storin& a list of rowids for each 3ey correspondin& to the rows with that 3ey value. Oracle stores each 3ey value repeatedly with each stored rowid. Q. What are the different t;pes of indeEes supported >; !racle? #he different types of inde+es area. 9>tree inde+es b. 9>tree cluster inde+es c. (ash cluster inde+es d. !everse 3ey inde+es e. 9itmap inde+es Q. 8an :e ha@e function >ased indeEes? @es, we can create inde+es on functions and e+pressions that involve one or more columns in the table bein& inde+ed. A function>based inde+ precomputes the value of the function or e+pression and stores it in the inde+. @ou can create a function>based inde+ as either a 9>tree or a bitmap inde+.

Page 14 of 29

Q. What are the restrictions on function >ased indeEes? #he function used for buildin& the inde+ can be an arithmetic e+pression or an e+pression that contains a E/G*?/ function, pac3a&e function, 0 callout, or *?/ function. #he e+pression cannot contain any a&&re&ate functions, and it must be C)#)!"%;%*#%0. or buildin& an inde+ on a column containin& an object type, the function can be a method of that object, such as a map method. (owever, you cannot build a function>based inde+ on a /O9 column, !) , or nested table column, nor can you build a function>based inde+ if the object type contains a /O9, !) , or nested table. Q. What are the ad@anta=es of ha@in= a $Ltree indeE? #he major advanta&es of havin& a 9>tree inde+ are7. 9>trees provide e+cellent retrieval performance for a wide ran&e of queries, includin& e+act match and ran&e searches. 4. %nserts, updates, and deletes are efficient, maintainin& 3ey order for fast retrieval. H. 9>tree performance is &ood for both small and lar&e tables, and does not de&rade as the size of a table &rows. Q. What is a >itmap indeE? (:E%# %nfotech, Eune) #he purpose of an inde+ is to provide pointers to the rows in a table that contain a &iven 3ey value. %n a re&ular inde+, this is achieved by storin& a list of rowids for each 3ey correspondin& to the rows with that 3ey value. Oracle stores each 3ey value repeatedly with each stored rowid. %n a bitmap inde+, a bitmap for each 3ey value is used instead of a list of rowids. )ach bit in the bitmap corresponds to a possible rowid. %f the bit is set, then it means that the row with the correspondin& rowid contains the 3ey value. A mappin& function converts the bit position to an actual rowid, so the bitmap inde+ provides the same functionality as a re&ular inde+ even thou&h it uses a different representation internally. %f the number of different 3ey values is small, then bitmap inde+es are very space efficient. 9itmap inde+in& efficiently mer&es inde+es that correspond to several conditions in a '()!) clause. !ows that satisfy some, but not all, conditions are filtered out before the table itself is accessed. #his improves response time, often dramatically. Q. What are the ad@anta=es of ha@in= >itmap indeE for data :arehousin= applications? (:E%# %nfotech, Eune) 9itmap inde+in& benefits data warehousin& applications which have lar&e amounts of data and ad hoc queries but a low level of concurrent transactions. or such applications, bitmap inde+in& provides7. !educed response time for lar&e classes of ad hoc queries 4. A substantial reduction of space usa&e compared to other inde+in& techniques H. Cramatic performance &ains even on very low end hardware N. Bery efficient parallel C"/ and loads ?. 'hat is the advanta&e of bitmap inde+ over 9>tree inde+Y ully inde+in& a lar&e table with a traditional 9>tree inde+ can be prohibitively e+pensive in terms of space since the inde+ can be several times lar&er than the data in the table. 9itmap inde+es are typically only a fraction of the size of the inde+ed data in the table. ?. 'hat is the limitationGdrawbac3 of a bitmap inde+Y

Page 15 of 29

9itmap inde+es are not suitable for O/#E applications with lar&e numbers of concurrent transactions modifyin& the data. #hese inde+es are primarily intended for decision support in data warehousin& applications where users typically query the data rather than update it. 9itmap inde+es are not suitable for hi&h>cardinality data. ?. (ow do you choose between 9>tree inde+ and bitmap inde+Y #he advanta&es of usin& bitmap inde+es are &reatest for low cardinality columns- that is, columns in which the number of distinct values is small compared to the number of rows in the table. %f the values in a column are repeated more than a hundred times, then the column is a candidate for a bitmap inde+. )ven columns with a lower number of repetitions and thus hi&her cardinality, can be candidates if they tend to be involved in comple+ conditions in the '()!) clauses of queries. or e+ample, on a table with one million rows, a column with 7O,OOO distinct values is a candidate for a bitmap inde+. A bitmap inde+ on this column can out>perform a 9>tree inde+, particularly when this column is often queried in conjunction with other columns. 9>tree inde+es are most effective for hi&h>cardinality data- that is, data with many possible values, such as 0,*#O")!A;A") or E(O;)A;,"9)!. A re&ular 9tree inde+ can be several times lar&er than the inde+ed data. ,sed appropriately, bitmap inde+es can be si&nificantly smaller than a correspondin& 9>tree inde+. Q. What are clusters? 0lusters are an optional method of storin& table data. A cluster is a &roup of tables that share the same data bloc3s because they share common columns and are often used to&ether. or e+ample, the )"E and C)E# table share the C)E#;O column. 'hen you cluster the )"E and C)E# tables, Oracle physically stores all rows for each department from both the )"E and C)E# tables in the same data bloc3s. Q. What is partitionin=? (:E%# %nfotech, Eune) Eartitionin& addresses the 3ey problem of supportin& very lar&e tables and inde+es by allowin& you to decompose them into smaller and more mana&eable pieces called partitions. Once partitions are defined, *?/ statements can access and manipulate the partitions rather than entire tables or inde+es. Eartitions are especially useful in data warehouse applications, which commonly store and analyze lar&e amounts of historical data. Q. What are the different partitionin= methods? #wo primary methods of partitionin& are available7. ran&e partitionin&, which partitions the data in a table or inde+ accordin& to a ran&e of values, and 4. hash partitionin&, which partitions the data accordin& to a hash function. Another method, composite partitionin&, partitions the data by ran&e and further subdivides the data into sub partitions usin& a hash function. Q. What is the necessit; to ha@e ta>le partitions? #he need to partition lar&e tables is driven by Cata 'arehouse and 9usiness %ntelli&ence demands for ad hoc analysis on &reat quantities of historical data 0heaper dis3 stora&e

Page 19 of 29

Application performance failure due to use of traditional techniques

Q. What are the ad@anta=es of storin= each partition in a separate ta>lespace? #he major advanta&es are7. @ou can contain the impact of data corruption. 4. @ou can bac3 up and recover each partition or subpartition independently. H. @ou can map partitions or subpartitions to dis3 drives to balance the %GO load. Q. What are the ad@anta=es of partitionin=? Eartitionin& is useful for7. Bery /ar&e Catabases (B/C9s) 4. !educin& Cowntime for *cheduled "aintenance H. !educin& Cowntime Cue to Cata ailures N. C** Eerformance M. %GO Eerformance D. Cis3 *tripin&- Eerformance versus Availability J. Eartition #ransparency Q. What is #an=e artitionin=? (:E%# %nfotech, Eune) !an&e partitionin& maps rows to partitions based on ran&es of column values. !an&e partitionin& is defined by the partitionin& specification for a table or inde+EA!#%#%O; 9@ !A;<) ( columnAlist ) and by the partitionin& specifications for each individual partitionBA/,)* /)** #(A; ( valueAlist ) ?. 'hat is (ash Eartitionin&Y (ash partitionin& uses a hash function on the partitionin& columns to stripe data into partitions. (ash partitionin& allows data that does not lend itself to ran&e partitionin& to be easily partitioned for performance reasons such as parallel C"/, partition prunin&, and partition>wise joins. ?. 'hat are the advanta&es of (ash partitionin& over !an&e Eartitionin&Y (ash partitionin& is a better choice than ran&e partitionin& whena) @ou do not 3now beforehand how much data will map into a &iven ran&e b) *izes of ran&e partitions would differ quite substantially c) Eartition prunin& and partition>wise joins on a partitionin& 3ey are important ?. 'hat are the rules for partitionin& a tableY A table can be partitioned ifZ %t is not part of a cluster Z %t does not contain /O;< or /O;< !A' datatypes ?. 'hat is a &lobal partitioned inde+Y %n a &lobal partitioned inde+, the 3eys in a particular inde+ partition may refer to rows stored in more than one underlyin& table partition or subpartition. A &lobal inde+ can only be ran&e> partitioned, but it can be defined on any type of partitioned table. Q. What is a local indeE?

Page 26 of 29

%n a local inde+, all 3eys in a particular inde+ partition refer only to rows stored in a sin&le underlyin& table partition. A local inde+ is created by specifyin& the /O0A/ attribute. Q. What are 8%!$ and N8%!$ datat;pes? ("ascot) #he 0/O9 and ;0/O9 datatypes store up to four &i&abytes of character data in the database. 0/O9s store sin&le>byte character set data and ;0/O9s store fi+ed>width and varyin&>width multibyte national character set data (;0(A! data). ?. 'hat is E/G*?/Y E/G*?/ is Oracle$s procedural lan&ua&e e+tension to *?/. E/G*?/ enables you to mi+ *?/ statements with procedural constructs. 'ith E/G*?/, you can define and e+ecute E/G*?/ pro&ram units such as procedures, functions, and pac3a&es. E/G*?/ pro&ram units &enerally are cate&orized as anonymous bloc3s and stored procedures. ?. 'hat is an anonymous bloc3Y An anonymous bloc3 is a E/G*?/ bloc3 that appears within your application and it is not named or stored in the database. ?. 'hat is a *tored ErocedureY A stored procedure is a E/G*?/ bloc3 that Oracle stores in the database and can be called by name from an application. 'hen you create a stored procedure, Oracle parses the procedure and stores its parsed representation in the database. ?. 'hat is a distributed transactionY A distributed transaction is a transaction that includes one or more statements that update data on two or more distinct nodes of a distributed database. Q. What are pac?a=es? (:E%# %nfotech, Eune) A pac3a&e is a &roup of related procedures and functions, to&ether with the cursors and variables they use, stored to&ether in the database for continued use as a unit. 'hile pac3a&es allow the administrator or application developer the ability to or&anize such routines, they also offer increased functionality (for e+ample, &lobal pac3a&e variables can be declared and used by any procedure in the pac3a&e) and performance (for e+ample, all objects of the pac3a&e are parsed, compiled, and loaded into memory once). Q. What are procedures and functions? (:E%# %nfotech, Eune) A procedure or function is a schema object that consists of a set of *?/ statements and other E/G*?/ constructs, &rouped to&ether, stored in the database, and e+ecuted as a unit to solve a specific problem or perform a set of related tas3s. Erocedures and functions permit the caller to provide parameters that can be input only, output only, or input and output values. Q. What is the difference >et:een rocedure and Aunction? Erocedures and functions are identical e+cept that functions always return a sin&le value to the caller, while procedures do not return values to the caller.

Page 21 of 29

?. 'hat is a C"/ and what do they doY Cata manipulation lan&ua&e (C"/) statements query or manipulate data in e+istin& schema objects. #hey enable you to7. !etrieve data from one or more tables or views (*)/)0#) 4. Add new rows of data into a table or view (%;*)!#) H. 0han&e column values in e+istin& rows of a table or view (,ECA#)) N. !emove rows from tables or views (C)/)#)) M. *ee the e+ecution plan for a *?/ statement ()RE/A%; E/A;) D. /oc3 a table or view, temporarily limitin& other users$ access (/O0: #A9/)) ?. 'hat is a CC/ and what do they doY Cata definition lan&ua&e (CC/) statements define, alter the structure of, and drop schema objects. CC/ statements enable you to7. 0reate, alter, and drop schema objects and other database structures, includin& the database itself and database users (0!)A#), A/#)!, C!OE) 4. 0han&e the names of schema objects (!);A")) H. Celete all the data in schema objects without removin& the objects$ structure (#!,;0A#)) N. <ather statistics about schema objects, validate object structure, and list chained rows within objects (A;A/@K)) M. <rant and revo3e privile&es and roles (<!A;#, !)BO:)) D. #urn auditin& options on and off (A,C%#, ;OA,C%#) J. Add a comment to the data dictionary (0O"");#) Q. What are shared sqlMs? Oracle automatically notices when applications send identical *?/ statements to the database. #he *?/ area used to process the first occurrence of the statement is shared[that is, used for processin& subsequent occurrences of that same statement. #herefore, only one shared *?/ area e+ists for a unique statement. *ince shared *?/ areas are shared memory areas, any Oracle process can use a shared *?/ area. #he sharin& of *?/ areas reduces memory usa&e on the database server, thereby increasin& system throu&hput. Q. What are tri==ers? Oracle allows to define procedures called tri&&ers that e+ecute implicitly when an %;*)!#, ,ECA#), or C)/)#) statement is issued a&ainst the associated table or, in some cases, a&ainst a view, or when database system actions occur. #hese procedures can be written in E/G*?/ or Tava and stored in the database, or they can be written as 0 callouts. Q. What is 8ostL>ased !ptimiDation? ,sin& the cost>based approach, the optimizer determines which e+ecution plan is most efficient by considerin& available access paths and factorin& in information based on statistics for the schema objects (tables or inde+es) accessed by the *?/ statement. Q. What is #uleL$ased !ptimiDation? ,sin& the rule>based approach, the optimizer chooses an e+ecution plan based on the access paths available and the ran3s of these access paths. Q. What is meant >; de=ree of parallelism?

Page 22 of 29

#he number of parallel e+ecution servers associated with a sin&le operation is 3nown as the de&ree of parallelism. Q. What is meant >; data consistenc;? Cata consistency means that each user sees a consistent view of the data, includin& visible chan&es made by the user$s own transactions and transactions of other users. Q. What are %oc?s? /oc3s are mechanisms that prevent destructive interaction between transactions accessin& the same resource[either user objects such as tables and rows or system objects not visible to users, such as shared data structures in memory and data dictionary rows. Q. What are the loc?in= modes used in !racle? Oracle uses two modes of loc3in& in a multiuser database)+clusive loc3 mode- Erevents the associates resource from bein& shared. #his loc3 mode is obtained to modify data. #he first transaction to loc3 a resource e+clusively is the only transaction that can alter the resource until the e+clusive loc3 is released. *hare loc3 mode- Allows the associated resource to be shared, dependin& on the operations involved. "ultiple users readin& data can share the data, holdin& share loc3s to prevent concurrent access by a writer (who needs an e+clusive loc3). *everal transactions can acquire share loc3s on the same resource. Q. What is a deadloc?? A deadloc3 can occur when two or more users are waitin& for data loc3ed by each other. Q. 9o: can ;ou a@oid deadloc?s? "ultitable deadloc3s can usually be avoided if transactions accessin& the same tables loc3 those tables in the same order, either throu&h implicit or e+plicit loc3s. or e+ample, all application developers mi&ht follow the rule that when both a master and detail table are updated, the master table is loc3ed first and then the detail table. %f such rules are properly desi&ned and then followed in all applications, deadloc3s are very unli3ely to occur. Q. What is redo lo=? #he redo lo&, present for every Oracle database, records all chan&es made in an Oracle database. #he redo lo& of a database consists of at least two redo lo& files that are separate from the datafiles (which actually store a database$s data). As part of database recovery from an instance or media failure, Oracle applies the appropriate chan&es in the database$s redo lo& to the datafiles, which updates database data to the instant that the failure occurred. A database$s redo lo& can consist of two parts- the online redo lo& and the archived redo lo&. Q. What are #oll>ac? 1e=ments? !ollbac3 se&ments are used for a number of functions in the operation of an Oracle database. %n &eneral, the rollbac3 se&ments of a database store the old values of data chan&ed by on&oin& transactions for uncommitted transactions. Amon& other thin&s, the information in a rollbac3 se&ment is used durin& database recovery to undo any uncommitted chan&es applied from the redo lo& to the datafiles. #herefore, if database recovery is necessary, then the data is in a consistent state after the rollbac3 se&ments are used to remove all uncommitted data from the datafiles. Q. What is 1"A?

Page 20 of 29

#he *ystem <lobal Area (*<A) is a shared memory re&ion that contains data and control information for one Oracle instance. An *<A and the Oracle bac3&round processes constitute an Oracle instance. Oracle allocates the system &lobal area when an instance starts and deallocates it when the instance shuts down. )ach instance has its own system &lobal area. ,sers currently connected to an Oracle server share the data in the system &lobal area. or optimal performance, the entire system &lobal area should be as lar&e as possible (while still fittin& in real memory) to store as much data in memory as possible and minimize dis3 %GO. #he information stored within the system &lobal area is divided into several types of memory structures, includin& the database buffers, redo lo& buffer, and the shared pool. #hese areas have fi+ed sizes and are created durin& instance startup. Q. What is 87A#EE? #he E0# !)) parameter sets the minimum percenta&e of a data bloc3 to be reserved as free space for possible updates to rows that already e+ist in that bloc3. Q. What is 8731ED? #he E0#,*)C parameter sets the minimum percenta&e of a bloc3 that can be used for row data plus overhead before new rows will be added to the bloc3. After a data bloc3 is filled to the limit determined by E0# !)), Oracle considers the bloc3 unavailable for the insertion of new rows until the percenta&e of that bloc3 falls below the parameter E0#,*)C. ,ntil this value is achieved, Oracle uses the free space of the data bloc3 only for updates to rows already contained in the data bloc3. Notes2 ;ulls are stored in the database if they fall between columns with data values. %n these cases they require one byte to store the len&th of the column (zero). #railin& nulls in a row require no stora&e because a new row header si&nals that the remainin& columns in the previous row are null. or e+ample, if the last three columns of a table are null, no information is stored for those columns. %n tables with many columns, the columns more li3ely to contain nulls should be defined last to conserve dis3 space. #wo rows can both contain all nulls without violatin& a unique inde+. ;,// values in inde+es are considered to be distinct e+cept when all the non>;,// values in two or more rows of an inde+ are identical, in which case the rows are considered to be identical. #herefore, ,;%?,) inde+es prevent rows containin& ;,// values from bein& treated as identical. 9itmap inde+es include rows that have ;,// values, unli3e most other types of inde+es. %nde+in& of nulls can be useful for some types of *?/ statements, such as queries with the a&&re&ate function 0O,;#. 9itmap inde+es on partitioned tables must be local inde+es.

PL/SQL is Orac*e7s procedura* *anguage e+tension to 8$, P$9 8$ com/ines t&e ease and f*e+i/i*it- of 8$ .it& t&e procedura* functiona*it- of a structured programming *anguage, suc& as IF ,,, T:EN, ;:I$E, and $OOP, ;&en designing a data/ase app*ication, a de<e*oper s&ou*d consider t&e ad<antages of using stored P$9 8$= (ecause P$9 8$ code can /e stored centra**- in a data/ase, net.or> traffic /et.een app*ications and t&e data/ase is reduced, so app*ication and s-stem

Page 21 of 29

performance increases, 'ata access can /e contro**ed /- stored P$9 8$ code, In t&is case, t&e users of P$9 8$ can access data on*- as intended /- t&e app*ication de<e*oper (un*ess anot&er access route is granted%, P$9 8$ /*oc>s can /e sent /- an app*ication to a data/ase, e+ecuting comp*e+ operations .it&out e+cessi<e net.or> traffic, E<en .&en P$9 8$ is not stored in t&e data/ase, app*ications can send /*oc>s of P$9 8$ to t&e data/ase rat&er t&an indi<idua* 8$ statements, t&ere/- again reducing net.or> traffic, T&e fo**o.ing sections descri/e t&e different program units t&at can /e defined and stored centra**- in a data/ase,

8ommittin= and #ollin= $ac? 7ransactions


T&e c&anges made /- t&e 8$ statements t&at constitute a transaction can /e eit&er committed or ro**ed /ac>, #fter a transaction is committed or ro**ed /ac>, t&e ne+t transaction /egins .it& t&e ne+t 8$ statement, Committing a transaction ma>es permanent t&e c&anges resu*ting from a** 8$ statements in t&e transaction, T&e c&anges made /- t&e 8$ statements of a transaction /ecome <isi/*e to ot&er user sessions7 transactions t&at start on*- after t&e transaction is committed, Rolling back a transaction retracts an- of t&e c&anges resu*ting from t&e 8$ statements in t&e transaction, #fter a transaction is ro**ed /ac>, t&e affected data is *eft unc&anged as if t&e 8$ statements in t&e transaction .ere ne<er e+ecuted,

0ntroduction to the Data Dictionar;


One of t&e most important parts of an Orac*e data/ase is its data dictionary, .&ic& is a read-only set of ta/*es t&at pro<ides information a/out its associated data/ase, # data dictionar- contains= T&e definitions of a** sc&ema o/?ects in t&e data/ase (ta/*es, <ie.s, inde+es, c*usters, s-non-ms, sequences, procedures, functions, pac>ages, triggers, and so on% :o. muc& space &as /een a**ocated for, and is current*- used /-, t&e sc&ema o/?ects 'efau*t <a*ues for co*umns Integrit- constraint information T&e names of Orac*e users Pri<i*eges and ro*es eac& user &as /een granted #uditing information, suc& as .&o &as accessed or updated <arious sc&ema o/?ects Ot&er genera* data/ase information T&e data dictionar- is structured in ta/*es and <ie.s, ?ust *i>e ot&er data/ase data, #** t&e data dictionar- ta/*es and <ie.s for a gi<en data/ase are stored in t&at data/ase7s ) TE" ta/*espace, Not on*- is t&e data dictionar- centra* to e<er- Orac*e data/ase, it is an important too* for a** users, from end users to app*ication designers and data/ase administrators, To access t&e data dictionar-, -ou use 8$ statements, (ecause t&e data dictionar- is read@on*-, -ou can issue on*- queries ( E$E!T statements% against t&e ta/*es and <ie.s of t&e data dictionar-, Q. What is the function of D3MMH ta>le? #he table named C,A/ is a small table in the data dictionary that Oracle and user written pro&rams can reference to &uarantee a 3nown result. #his table has one column called C,""@ and one row containin& the value "R".

Page 22 of 29

'ata/ases, ta/*espaces, and datafie*s are c*ose*- re*ated, /ut t&e- &a<e important differences= 'ata/ases and ta/*espaces= #n Orac*e data/ase consists of one or more *ogica* storage units ca**ed ta/*espaces, .&ic& co**ecti<e*- store a** of t&e data/ase7s data, Ta/*espaces and datafi*es= Eac& ta/*e in an Orac*e data/ase consists of one or more fi*es ca**ed datafi*es, .&ic& are p&-sica* structures t&at conform .it& t&e operating s-stem in .&ic& Orac*e is running, data/ases and datafi*es= # data/ase7s data is co**ecti<e*- stored in t&e datafi*es t&at constitute eac& ta/*espace of t&e data/ase, For e+amp*e, t&e simp*est Orac*e data/ase .ou*d &a<e one ta/*espace and one datafi*e, #not&er data/ase mig&t &a<e t&ree ta/*espaces, eac& consisting of t.o datafi*es (for a tota* of si+ datafi*es%,

Nulls
# null is t&e a/sence of a <a*ue in a co*umn of a ro., Nu**s indicate missing, un>no.n, or inapp*ica/*e data, # nu** s&ou*d not /e used to imp*- an- ot&er <a*ue, suc& as Aero, # co*umn a**o.s nu**s un*ess a NOT NU$$ or PRI"#R) BE) integrit- constraint &as /een defined for t&e co*umn, in .&ic& case no ro. can /e inserted .it&out a <a*ue for t&at co*umn, Nu**s are stored in t&e data/ase if t&e- fa** /et.een co*umns .it& data <a*ues, In t&ese cases t&e- require one /-te to store t&e *engt& of t&e co*umn (Aero%, Trai*ing nu**s in a ro. require no storage /ecause a ne. ro. &eader signa*s t&at t&e remaining co*umns in t&e pre<ious ro. are nu**, For e+amp*e, if t&e *ast t&ree co*umns of a ta/*e are nu**, no information is stored for t&ose co*umns, In ta/*es .it& man- co*umns, t&e co*umns more *i>e*- to contain nu**s s&ou*d /e defined *ast to conser<e dis> space, "ost comparisons /et.een nu**s and ot&er <a*ues are /- definition neit&er true nor fa*se, /ut un>no.n, To identif- nu**s in 8$, use t&e I NU$$ predicate, Use t&e 8$ function NC$ to con<ert nu**s to non@nu** <a*ues, Nu**s are not inde+ed, e+cept .&en t&e c*uster >e- co*umn <a*ue is nu** or t&e inde+ is a /itmap inde+, 'hat are different types of loc3sY Q. Master ta>le and 8hild ta>le performances and comparisons in !racle? Q. What are the different t;pes of 8ursors? EEplain. ((oneywell) Q. What are the different t;pes of Deletes? Q. 8an a Cie: >e updated?

Interview Questions from Honeywell 1, ;&at is pragmaD 2, !an -ou .rite commit in triggersD 0, !an -ou ca** user defined functions in se*ect statements 1, !an -ou ca** insert9update9de*ete in se*ect statements, If -es &o.D If no .&at is t&e ot&er .a-D

Page 23 of 29

2, #fter update &o. do -ou >no., &o. man- records got updated 3, e*ect statement does not retrie<e an- records, ;&at e+ception is raisedD
0nter@ie: Questions from 1hreesoft

1, :o. man- co*umns can a P$ 8$ ta/*e &a<e


0nter@ie: Questions from mascot

1, ;&at is $oad /a*ancing E .&at u &a<e used to do t&isD ( 8$ $oader % 2, ;&at r RoutersD

PL/SQL 1. 2. !. #. '. ,. -. What are different types of joins? Difference between Packages and Proced res Difference between " nction and Proced res $ow %any types of triggers are there? When do yo (an yo write DDL state%ents in &riggers? )*o+ What is $int? $ow do yo t ne a SQL . ery?

se &riggers

%nterview ?uestions from :E%# %nfotech, Eune

1, Pac>age /od2, ;&at is mo*ar quer-D


H. 'hat is row level security

<eneral-

;&- OR#!$E is t&e /est data/ase for 'ata.are&ousing For data *oading in Orac*e, .&at are con<entiona* *oading and direct@pat& *oading D 4, If -ou use orac*e 8$F$oader, &o. do -ou transform data .it& it during *oading D E+amp*e, T&ree .a-s 8$F$oader cou*d doad data, .&at are t&ose t&ree t-pes D ;&at are t&e contents of G/ad fi*esG and Gdiscard fi*esG .&en using 8$F$oader D :o. do -ou use commit frequencies D &o. does it affect *oading performance D ;&at are t&e ot&er factors of t&e data/ase on .&ic& t&e *oading performance depend D F ;:#T I P#R#$$E$I " D F ;:#T I # P#R#$$E$ 8UER) D F ;:#T #RE 'IFFERENT ;#) OF $O#'INH '#T# TO '#T#;#RE:OU E U INH OR#!$ED F ;:#T I T#($E P#RTITIONINHD :O; IT I U EFU$ TO ;#RE:OU E '#T#(# ED F ;:#T #RE 'IFFERENT T)PE OF P#RTITIONINH IN OR#!$ED F ;:#T I # "#TERI#$IIE' CIE;D :O; IT I 'IFFERENT FRO" NOR"#$ #N' IN$INE CIE; D Page 24 of 29

F ;:#T I IN'EJINHD ;:#T #RE 'IFFERENT T)PE OF IN'EJE UPPORTE' () OR#!$ED F ;:#T #RE 'IFFERENT TOR#HE OPTION UPPORTE' () OR#!$ED F ;:#T I 8UER) OPTI"IIERD ;:#T #RE 'IFFERENT T)PE OF OPTI"IIER UPPORTE' () OR#!$ED F EJP$#IN RO$$UP,!U(E,R#NB #N' 'EN EKR#NB FUN!TION OF OR#!$E 5i,
T&e ad<antages of using /itmap inde+es are greatest for *o. cardina*it- co*umns= t&at is, co*umns in .&ic& t&e num/er of distinct <a*ues is sma** compared to t&e num/er of ro.s in t&e ta/*e, # gender co*umn, .&ic& on*- &as t.o distinct <a*ues (ma*e and fema*e%, is idea* for a /itmap inde+, :o.e<er, data .are&ouse administrators .i** a*so c&oose to /ui*d /itmap inde+es on co*umns .it& muc& &ig&er cardina*ities, /ocal vs &lobal- # (@tree inde+ on a partitioned ta/*e can /e *oca* or g*o/a*, H*o/a* inde+es must /e fu**- re/ui*t after a direct *oad, .&ic& can /e <er- cost*- .&en *oading a re*ati<e*sma** num/er of ro.s into a *arge ta/*e, For t&is reason, it is strong*- recommended t&at inde+es on partitioned ta/*es s&ou*d /e defined as *oca* inde+es un*ess t&ere is a .e**@?ustified performance requirement for a g*o/a* inde+, (itmap inde+es on partitioned ta/*es are a*.a-s *oca*,

Wh; 8onstraints are 3seful in a Data Warehouse


!onstraints pro<ide a mec&anism for ensuring t&at data conforms to guide*ines specified /- t&e data/ase administrator, T&e most common t-pes of constraints inc*ude unique constraints (ensuring t&at a gi<en co*umn is unique%, not@nu** constraints, and foreign@>e- constraints (.&ic& ensure t&at t.o >e-s s&are a primar- >e-@foreign >e- re*ations&ip%,

MaterialiDed Cie:s for Data Warehouses


In data .are&ouses, materia*iAed <ie.s can /e used to precompute and store aggregated data suc& as t&e sum of sa*es, "ateria*iAed <ie.s in t&ese en<ironments are t-pica**- referred to as summaries, /ecause t&e- store summariAed data, T&ecan a*so /e used to precompute ?oins .it& or .it&out aggregations, # materia*iAed <ie. e*iminates t&e o<er&ead associated .it& e+pensi<e ?oins or aggregations for a *arge or important c*ass of queries,

7he Need for MaterialiDed Cie:s


"ateria*iAed <ie.s are used in data .are&ouses to increase t&e speed of queries on <er- *arge data/ases, 8ueries to *arge data/ases often in<o*<e ?oins /et.een ta/*es or aggregations suc& as U", or /ot&, T&ese operations are <er- e+pensi<e in terms of time and processing po.er, (ow does "B$s wor3Y T&e quer- optimiAer can use materia*iAed <ie.s /automatica**- recogniAing .&en an e+isting materia*iAed <ie. can and s&ou*d /e used to satisf- a request, It t&en transparent*- re.rites t&e request to use t&e materia*iAed <ie., 8ueries are t&en directed to t&e materia*iAed <ie. and not to t&e under*-ing detai* ta/*es, In genera*, re.riting queries to use materia*iAed <ie.s rat&er t&an detai* ta/*es resu*ts in a significant performance gain, If a materia*iAed <ie. is to /e used /- quer- re.rite, it must /e stored in t&e same data/ase as its fact or detai* ta/*es, # materia*iAed <ie. can /e partitioned, and -ou can define a materia*iAed <ie. on a partitioned ta/*e and one or more inde+es on

Page 25 of 29

t&e materia*iAed <ie., T&e t-pes of materia*iAed <ie.s are= "ateria*iAed Cie.s .it& Loins and #ggregates ing*e@Ta/*e #ggregate "ateria*iAed Cie.s "ateria*iAed Cie.s !ontaining On*- Loins *ome ,seful system tables-

userKta/Kpartitions

user_tab_columns

Page 29 of 29

Вам также может понравиться