You are on page 1of 151

1

ORACLE
COMPLETE
REFERENCE
Frequently asked Questions

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

2

1. Autonomous transaction:-

An autonomous transaction is an independent transaction that is initiated by another
transaction. It must contain at least one Structured Query Language (SQL) statement.
Autonomous transactions allow a single transaction to be subdivided into multiple
commit/rollback transactions, each of which will be tracked for auditing purposes.

When an autonomous transaction is called, the original transaction (calling
transaction) is temporarily suspended. The autonomous transaction must commit or
roll back 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
operate as a calling transaction, initializing other autonomous transactions within itself.
In theory, there is no limit to the possible number of nesting levels

2. Where we use bitmap index ?

Bitmap indexes are most appropriate for columns having low distinct values

3. What is an extent?

extent is the smallest unit of storage allocation comprising collecion of Blocks. , Well
an extent is a chunk of a space that is used by database segments when a segmant
is created it alocates extents.

4. Explain the difference between a hot backup and a cold backup and the benefits
associated with each.

A hot backup is basically taking a backup of the database while it is still up and
running and it must be in archive log mode. A cold backup is taking a backup of the
database while it is shut down and does not require being in archive log mode. The
benefit of taking a hot backup is that the database is still available for use while the
backup is occurring and you can recover the database to any point in time. The
benefit of taking a cold backup is that it is typically easier to administer the backup
and recovery process. In addition, since you are taking cold backups the database
does not require being in archive log mode and thus there will be a slight
performance gain as the database is not cutting archive logs to disk.

5. You have just had to restore from backup and do not have any control files. How
would you go about bringing up this database?

I would create a text based backup control file, stipulate where on disk all the data
files where and then issue the recover command with the using backup control file
clause.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

3

6. How do you switch from an init.ora file to a spfile?

Issue the create spfile from pfile command.

7. Explain the difference between a data block, an extent and a segment

A data block is the smallest unit of logical storage for a database object. As objects
grow they take chunks of additional storage that are composed of contiguous data
blocks. These groupings of contiguous data blocks are called extents. All the extents
that an object takes when grouped together are considered the segment of the
database object.

8. Give two examples of how you might determine the structure of the table DEPT.

Use the describe command or use the dbms_metadata.get_ddl package.

9. Where would you look for errors from the database engine?

In the alert log.

10. Compare and contrast TRUNCATE and DELETE for a table.

Both the truncate and delete command have the desired outcome of getting rid of
all the rows in a table. The difference between the two is that the truncate command
is a DDL operation and just moves the high water mark and produces a no rollback.
The delete command, on the other hand, is a DML operation, which will produce a
rollback and thus take longer to complete.

11. Give the reasoning behind using an index.

Faster access to data blocks in a table.

12. Give the two types of tables involved in producing a star schema and the type
of data they hold.

Fact tables and dimension tables. A fact table contains measurements while
dimension tables will contain data that will help describe the fact tables.

13. What type of index should you use on a fact table?

A Bitmap index.

14. Give two examples of referential integrity constraints.

A primary key and a foreign key.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

How would you go about increasing the buffer cache hit ratio? Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. How would you do this without affecting the children tables? Disable the foreign key constraint to the parent. re-create the table. NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any point in time. 16. enable the foreign key constraint.com . STARTUP NOMOUNT . ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that have occurred in the database so that you can recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an archive log and thus increases the performance of the database slightly. Give the stages of instance startup to a usable state where normal users may access it. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and disadvantages to each.sql or utlxpls.Instance startup STARTUP MOUNT . How would you go about generating an EXPLAIN plan? Create a plan table with utlxplan. If a change was necessary then I would use the alter system set db_cache_size command. drop the table. What command would you use to create a backup control file? Alter database backup control file to trace. 4 15.sql 21. 20.The database is opened 19.sql. What column differentiates the V$ views to the GV$ views and how? The INST_ID column which indicates the instance in a RAC environment the information came from. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. A table is classified as a parent table and you want to drop and re-create it. 17.The database is mounted STARTUP OPEN . Use the explain plan set statement_id = 'tst1' into plan_table for a SQL statement Look at the explain plan with utlxplp. 18.

5 22. It can usually be solved by increasing the undo retention or increasing the size of rollbacks. 29. How would you determine the time zone under which a database was operating? select DBTIMEZONE from dual. Explain an ORA-01555 You get this error when you get a snapshot too old within rollback. A function and procedure are the same in that they are intended to be a collection of PL/SQL code that carries a single task. A package on the other hand is a collection of functions and procedures that are grouped together based on their commonality to a business function or application. Where in the Oracle directory tree structure are audit traces placed? In unix $ORACLE_HOME/rdbms/audit. Setting GLOBAL_NAMES dictates how you might connect to a database. 23. They are also used to pipeline information in an ETL process. & Timed Statistics 30. 28. Table functions are designed to return a set of rows through PL/SQL logic but are intended to be used as a normal table or view in a SQL statement. This variable is either TRUE or FALSE and if it is set to TRUE it enforces database links to have the same name as the remote database to which they are linking. Explain the difference between a FUNCTION. Segment Level Statistics. 25. a function will return a single value. Buffer Cache Advice. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside. in Windows the event viewer Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. While a procedure does not have to return any values to the calling application. 26. Explain the use of table functions. 24. Explain the use of setting GLOBAL_NAMES equal to TRUE. What command would you use to encrypt a PL/SQL application? WRAP 27. Explain the difference between $ORACLE_HOME and $ORACLE_BASE. You should also look at the logic involved in the application getting the error message. PROCEDURE and PACKAGE. ORACLE_BASE is the root directory for oracle.com . Name three advisory statistics you can collect.

40. Materialized views are objects that are reduced sets of information that have been summarized. what background process cleans up after it? PMON 33. Describe what redo logs are. grouped. 36. Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database. How would you force a log switch? ALTER SYSTEM SWITCH LOGFILE. They are typically used in data warehouse or decision support systems. 34. You could use Logminer or Streams 38. When a user process fails. 37. Give two methods you could use to determine what DDL changes have been made. What does coalescing a tablespace do? Coalescing is only valid for dictionary-managed tablespaces and de-fragments space by combining neighboring free extents into large single extents. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Name a tablespace automatically created when you create a database. 39. 6 31. What background process refreshes materialized views? The Job Queue Processes.com . Explain materialized views and how they are used. How would you determine what sessions are connected and what resources they are waiting for? Use of V$SESSION and V$SESSION_WAIT 35. 32. or aggregated from base tables. What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace? A temporary tablespace is used for temporary objects such as sort structures while permanent tablespaces are used to store those objects meant to be used as the true objects of the database.

How would you determine who has added a row to a table? Turn on fine grain auditing for the table. 7 The SYSTEM tablespace. How can you gather statistics on a table? The ANALYZE command. 51.SET_SQL_TRACE OR ALTER SESSION SET SQL_TRACE = TRUE. 44. Explain what partitioning is and what its benefit is. When creating a user. 49. What is the difference between the SQL*Loader and IMPORT utilities? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. how would you view the errors? SHOW ERRORS 50. 47. 42. more manageable pieces. Partitioning is a method of taking large tables and indexes and splitting them into smaller. 52.com . How can you rebuild an index? ALTER INDEX <index_name> REBUILD. 41. ANALYZE TABLE <TAB NAME> COMPUTE STATISTICS. How do you resize a data file? ALTER DATABASE DATAFILE <datafile_name> RESIZE <new_size>. You have just compiled a PL/SQL package but got errors. How can you enable a trace for a session? DBMS_SESSION. How do you add a data file to a tablespace? ALTER TABLESPACE <tablespace_name> ADD DATAFILE <datafile_name> SIZE <size> 43. 48. what permissions must you grant to allow them to connect to the database? Grant the CONNECT to the user. What view would you use to determine free space in a tablespace? DBA_FREE_SPACE 46. What view would you use to look at the size of a data file? DBA_DATA_FILES 45.

This appends an OS-specific line terminator.ORA and SQLNET. 58. When applications developers demand the most powerful interface to the Oracle Database Server. 57. FOPEN function -Opens a file with the maximum line size specified. Form triggers on the other hand are fired in response to any event that takes place while working with the forms.00000 (Ten Lakhs) 55. Name two files used for network connection to a database. What is the maximum buffer size that can be specified using the DBMS_OUTPUT. PUT procedure-Writes a line to a file. This does not append a line terminator. What are its uses? OCI is Oracle Call Interface. It provides a restricted version of standard OS stream file input/output (I/O). What is OCI. UPATE. LOGON LOGOFF etc occurs.com . FFLUSH procedure-Physically writes all pending output to a file. 56. The newest performance. TNSNAMES. Difference between database triggers and form triggers? Database triggers are fired whenever any database action like INSERT. DELETE. 8 These two Oracle utilities are used for loading data into the database. NEW_LINE procedure-Writes one or more OS-specific line terminators to a file. and security features Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. scalability. Subprogram -Description FOPEN function-Opens a file for input or output with the default line size. IS_OPEN function -Determines if a file handle refers to an open file.ORA 54. Only if you are using autonomous transactions in the Database triggers. PUT_LINE procedure -Writes a line to a file. FCLOSE_ALL procedure -Closes all open file handles. they call upon the Oracle Call Interface (OCI).ENABLE function? 10. FCLOSE procedure -Closes a file. GET_LINE procedure -Reads a line of text from an open file. OCI provides the most comprehensive access to all of the Oracle Database functionality. PUTF procedure -A PUT procedure with formatting. What is an UTL_FILE? What are different procedures and functions associated with it? The UTL_FILE package lets your PL/SQL programs read and write operating system (OS) text files. 53. say like navigating from one field to another or one block to another and so on. The difference is that the import utility relies on the data being produced by another Oracle utility EXPORT while the SQL*Loader utility allows data to be loaded that has been produced by other utilities from different data sources just so long as it conforms to ASCII formatted or delimited files. Can you use a commit statement within a database trigger? Yes.

you likely already depend on OCI. 64. and IN OUT. IN . The precompiler accepts the source program as input. What is syntax for dropping a procedure and a function? Are these operations possible? Drop Procedure/Function . What are different modes of parameters used in functions and procedures? There are three different modes of parameters: IN. In other words. What are ORACLE PRECOMPILERS? A precompiler is a tool that allows programmers to embed SQL statements in high- level source programs like C. its IN parameters function like constants. If they are a part of a package then one have to remove it from the package definition and body and recompile the package. Just like constants. The actual parameters are the values or expressions placed in the parameter list of the actual call to the module.The IN parameter allows you to pass values in to the module. yes. SQLJ for Java etc. if they are standalone procedures or functions. Can a function take OUT parameters. What is difference between a formal and an actual parameter? The formal parameters are the names that are declared in the parameter list of the header of a module. OUT. Some types of applications that depend upon OCI are: · PL/SQL applications executing SQL · C++ applications using OCCI · Java applications using the OCI-based JDBC driver · C applications using the ODBC driver · VB applications using the OLEDB driver · Pro*C applications · Distributed SQL 59. 61. and generates a modified source program that one can compile. 63. the value of the formal IN parameter cannot be changed within the program. C++. COBOL. If not why? yes. 60.com . OUT or IN OUT. Pro*Cobol for Cobol. 9 appear first in the OCI API. In such case you don’t need to specify any value and the actual parameter will take the default value provided in the function definition. You cannot assign values to the IN parameter or in any other way modify its value. Can the default values be assigned to actual parameters? Yes. Examples are the Pro*C Precompiler for C. IN. translates the embedded SQL statements into standard Oracle runtime library calls. 62. but will not pass anything out of the module and back to the calling PL/SQL block. link. and execute in the usual way. If you write applications for the Oracle Database. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. for the purposes of the program. etc.

an OUT parameter acts like a variable that has not been initialised. When you call a function you must always assign its value to a variable. */ TYPE company_curtype IS REF CURSOR RETURN company%ROWTYPE. /* Fetch from the cursor variable. An OUT parameter is like the return value for a function. That value is then available in the calling PL/SQL block. you can pass values into the program and return a value back to the calling program (either the original. the value in that local copy is then transferred to the actual OUT parameter. */ OPEN company_curvar FOR SELECT * FROM company. In fact. */ company_curvar company_curtype. Inside the program. 66) Can cursor variables be stored in PL/SQL tables. DECLARE /* Create the cursor type. any assignments to an OUT parameter are actually made to an internal copy of the OUT parameter. A function always returns a value. If yes how. that is). An IN OUT actual parameter or argument must be a variable. The IN OUT parameter shares two restrictions with the OUT parameter: An IN OUT parameter cannot have a default value. */ company_rec company%ROWTYPE. have as many OUT parameters as you like. Create a cursor type . IN parameters can be given default values in the program header. 65) Difference between procedure and function. or expression. of course.REF CURSOR and declare a cursor variable of that type. /* Close the cursor object associated with variable. associating with it a SQL statement. BEGIN /* Open the cursor variable. since these formats do not provide a receptacle in which PL/SQL can place the outgoing value. */ FETCH company_curvar INTO company_rec. /* Declare a cursor variable of that type. unchanged value or a new value set within the program).With an IN OUT parameter. If not why? Yes. OUT .An OUT parameter is the opposite of the IN parameter.com . Use the OUT parameter to pass a value back from the program to the calling PL/SQL block. the OUT parameter has no value at all until the program terminates successfully (without raising an exception. IN OUT . /* Declare a record with same structure as cursor variable. while a procedure does not. It cannot be a constant. During the execution of the program. but it appears in the parameter list and you can. When the program terminates successfully and returns control to the calling block. literal. 10 IN is the default mode for parameters. */ Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.

68. FALSE otherwise. 71. How do you open and close a cursor variable. or you attempt to reference a row in the PL/SQL table which is not yet defined. The cursor must be opened before using it in order to fetch the result set of the query it is associated with. It is like a pointer in C or Pascal. %ROWCOUNT Returns number of records fetched from cursor at that point in time. A scalar data type like number or varchar can’t be used but a record type may evaluate to a scalar value. 73. which is a high percentage of the time with cursors. it is defined as TYPE REF CURSOR RETURN . Why it is required? Using OPEN cursor_name and CLOSE cursor_name commands.com . 72. What should be the return type for a cursor variable. Can we use a scalar data type as return type? The return type of a cursor variable can be %ROWTYPE or record_name%TYPE or a record type or a ref cursor type. %NOTFOUND Returns TRUE if record was not fetched successfully. or to free up the cursor variable to be opened again. How do you pass cursor variables in PL/SQL? Pass a cursor variable as an argument to a procedure or function. Use the cursor FOR loop whenever (and only if) you need to fetch and process each and every record from a cursor. SQL%NOTFOUND. What is use of a cursor variable? How it is defined? Cursor variable is used to mark a work area where Oracle stores a multi-row query output for processing. is a BOOLEAN attribute indicating whether the recent SQL statement does not match to any row. Both explicit and implicit cursors have four attributes. What are cursor attributes? Cursor attributes are used to get the information about the current status of your cursor. What WHERE CURRENT OF clause does in a cursor? The Where Current Of statement allows you to update or delete the record that was last fetched by the cursor. 11 CLOSE company_curvar. The cursor needs to be closed so as to release resources earlier than end of transaction. You can. in essence. END. 74. 69. FALSE otherwise. Difference between NO DATA FOUND and %NOTFOUND NO DATA FOUND is an exception which is raised when either an implicit query returns no data. What is a cursor for loop? A cursor FOR loop is a loop that is associated with (actually defined by) an explicit cursor or a SELECT statement incorporated directly within the loop boundary. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 70. 67. share the results of a cursor by passing the reference to that result set. as shown: Name Description %FOUND Returns TRUE if record was fetched successfully. Because it is a TYPE.

What is a pseudo column. Give some examples? Information such as sysdate .user identification number indicating the current user. not through tables.name of currently logged in user. ie. which are grouped together because they share common columns and are often used together. These pseudo columns can be retrieved in queries. Difference between an implicit & an explicit cursor. in the Where condition. For example. Select * from T1 where x in ( select y from T2 ) is typically processed as: select * from t1. 78. When you cluster the EMP and DEPT. A cluster is comprised of a group of tables that share the same data blocks. FALSE otherwise. Oracle physically stores all rows for each department from both the EMP and DEPT tables in the same data blocks. How you will avoid your query from using indexes? By changing the order of the columns that are used in the index. 81. You should not use clusters for tables that are frequently accessed individually. ( select distinct y from t2 ) t2 Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.system or today’s date. These pseudo columns can be included in queries which select data from tables. 76. the EMP and DEPT table share the DEPTNO column. Available Pseudo Columns · ROWNUM .com . 79. · SYSDATE . · USER . This information is contained within pseudo columns. · UID . row numbers and row descriptions are automatically stored by Oracle and is directly accessible. Which is more faster . 77. · ROWID . ie.IN or EXISTS? Well. What is the purpose of a cluster? A cluster provides an optional method of storing table data. 75.row number. Order number in which a row value is retrieved. What is a OUTER JOIN? An OUTER JOIN returns all rows that satisfy the join condition and also returns some or all of those rows from one table for which no rows from the other satisfy the join condition. 80. the two are processed very differently. The implicit cursor is used by Oracle server to test and parse the SQL statements and the explicit cursors are declared by the programmers. unique row identification. or by concatenating the columns with some constant values. 12 %ISOPEN Returns TRUE if cursor is open.physical row (memory or disk address) location. What is a cursor? A cursor is a mechanism by which you can assign a name to a “select statement” and manipulate the information within that SQL statement.

Lets say the result of the sub query is small — then IN is typically more appropriate. 84.y. As opposed to select * from t1 where exists ( select null from t2 where y = x ) That is processed more like: for x in ( select * from t1 ) loop if ( exists ( select null from t2 where y = x. indexed (or hashed or sorted) and then joined to the original table — typically. when is where exists appropriate and in appropriate? Lets say the result of the sub query ( select y from T2 ) is “huge” and takes a long time. 86. What will be the query to find it? SELECT column_name FROM table_name WHERE column_name LIKE ‘%\%%’ ESCAPE ‘\’. 87. SUBSTR function return a portion of string. substring_length characters long. 85. When do you use WHERE clause and when do you use HAVING clause? The WHERE condition lets you restrict the rows selected to those that satisfy one or more conditions. beginning at character position. Then the exists will be faster as the time to full scan T1 and do the index probe into T2 could be less then the time to simply full scan T2 to build the sub query we need to distinct on. SQL*PLUS is the tool that lets to use SQL to fetch and display the data. Use the HAVING clause to restrict the groups of returned rows to those groups for which the specified condition is TRUE. So. 82. But the table T1 is relatively small and executing ( select null from t2 where y = x. Which data type is used for storing graphics and images? Raw. If both the sub query and the outer table are huge — either might work as well as the other — depends on the indexes and other factors. SUBSTR calculates lengths using characters as defined by the input character set. distinct’ed.x ) is very fast (nice index on t2(y)). What is difference between SQL and SQL*PLUS? SQL is the query language to manipulate the data from the database. There is a % sign in one field of a column. 83. and BLOB. The sub query is evaluated.x = t2. What is difference between SUBSTR and INSTR? INSTR function search string for sub-string and returns an integer indicating the position of the character in string that is the first character of this occurrence. 13 where t1.com .x ) then OUTPUT THE RECORD end if end loop It always results in a full scan of T1 whereas the first query can make use of an index on T1(x). What is difference between UNIQUE and PRIMARY KEY constraints? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Long Raw.

CREATE INDEX sales_margin_inx ON sales(revenue . We have to enable Function-based indexes by enableing the following initialization parameters ALTER SESSION SET QUERY_REWRITE_ENABLED = TRUE. function and anonymous pl/sql block.explain? Function-based indexes can use any Function or Object method that is declared as repeatable.(to_char(to_date(sal. . Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column which do not exist once the SQL statement is executed.cost) > 1000.cost).. 93. What is the difference between Hot Backup and Cold Backup? Hot Backup : It is tablespace wise backup. 4712 BC and sp means to spell out. troublefree. Ex:.. temp. the number of days since January 1. J means Julian day. Disadvantage. Display the number value in Words? A)select sal. 89.not for production. Describe the difference between a procedure.Restores all the old valid backup & apply the archive log. NOT EXISTS. 90. NOT IN.’j'). What is difference between Rename and Alias? Rename is actually changing the name of an object whereas Alias is giving another name (additional name) to an existing object. Both bears unique values. 92.Safest. EXISTS. Sql> SELECT ordid FROM sales WHERE (revenue . Advantage . IN ANY. ALTER SESSION SET QUERY_REWRITE_INTEGRITY = TRUSTED. IN ALL. can be used for Online Banking etc. What is a functional index ..Restores all the data files. Archive log mode. 91. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. IN.) Advantage. 88.While the DB is on the backup can be taken. 14 An UNIQUE key can have NULL whereas PRIMARY key is always not NOT NULL. control files(log files. What are various joins used while writing SUBQUERIES? A) =.’jsp’)) from emp.com . Disadvantage - Cold Backup : Shutdown cleanly and then the backup is taken. Queries using expressions can use the index.

In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the %NOTFOUND cursor variable in the exit when statement? Why? OPEN then FETCH then LOOP followed by the exit when. DBMS_PIPE. 97. DBMS_OUTPUT. Describe the use of %ROWTYPE and %TYPE in PL/SQL %ROWTYPE allows you to associate a variable with an entire table row. DBMS_LOCK. DBMS_DDL. UTL_FILE. 99. 95. If not specified in this order will result in the final return being done twice because of the way the %NOTFOUND is handled by PL/SQL. What are SQLCODE and SQLERRM and why are they important for PL/SQL developers? SQLCODE returns the value of the error number for the last error encountered. These are especially useful for the WHEN OTHERS exception. or RECORD. but not really what was asked. They can be used to hold values for use in later queries or calculations. non-stored PL/SQL procedures. DBMS_JOB. The SQLERRM returns the actual error message for the last error encountered. In Oracle 8 they will be able to be of the %ROWTYPE designation. a function must return a value while a procedure doesn?t have to. The usual fix involves either use of views or temporary tables so the database is selecting from one while updating the other. great. The %TYPE associates a variable with a single column type. There are many which developers should be aware of such as DBMS_SQL. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Describe the use of PL/SQL tables PL/SQL tables are scalar arrays that can be referenced by a binary integer. 96. or.com . They can be used in exception handling to report. What packages (if any) has Oracle provided for use by developers? Oracle provides the DBMS_ series of packages. 98. 94. DBMS_ALERT. If they can mention a few of these and describe how they used them. the error that occurred in the code. What is a mutating table error and how can you get around it? This happens with triggers. even better. DBMS_TRANSACTION. 100. When is a declare statement needed ? The DECLARE statement is used in PL/SQL anonymous blocks such as with stand alone. If they include the SQL routines provided by Oracle. store in an error log table. DBMS_UTILITY. It must come first in a PL/SQL stand alone file if it is used. It occurs because the trigger is trying to update a row it is currently using. 15 Candidate should mention use of DECLARE statement.

104 . SHRINK command. The packages used by DBAs may include: DBMS_SHARED_POOL. How can you find within a PL/SQL block. You have a rollback segment in a version 7. how can it be restored to optimal? Use the ALTER TABLESPACE . the error is ignored and the tables data will be inserted.. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. The DBMS_OUTPUT package can be used to show intermediate results from loops and the status of variables as the procedure is executed. INSERT. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER command what happens? Is this bad or good? Why? The user is assigned the SYSTEM tablespace as a default and temporary tablespace. The default value is N. How can you generate debugging output from PL/SQL? Use the DBMS_OUTPUT package.. 103. This is bad because it causes user objects and temporary segments to be placed into the SYSTEM tablespace resulting in fragmentation and improper table placement (only data dictionary objects and the system rollback segment should be in SYSTEM). What are the types of triggers? There are 12 types of triggers in PL/SQL that consist of combinations of the BEFORE.. or COPY. The new package UTL_FILE can also be used. Give one method for transferring a table from one schema to another: There are several possible methods. 102. 105. AFTER. ROW. Another possible method is to just use the SHOW ERROR command.. 108.com . TABLE. 16 101. but this only shows errors. CREATE TABLE. UPDATE. if a cursor is open? Use the %ISOPEN cursor status variable. What is the purpose of the IMPORT option IGNORE? What is it?s default setting? The IMPORT IGNORE option tells import to ignore "already exists" errors. What are some of the Oracle provided packages that DBAs should be aware of? Oracle provides a number of packages in the form of the DBMS_ packages owned by the SYS user..2 database that has expanded beyond optimal. 107. If it is specified. AS SELECT.. If it is not specified the tables that already exist will be skipped. DELETE and ALL key words: BEFORE ALL ROW INSERT AFTER ALL ROW INSERT BEFORE INSERT AFTER INSERT etc. 106. export-import.

DBMS_DDL. for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys. 109. (On UNIX) When should more than one DB writer process be used? How many should be used? If the UNIX system being used is capable of asynchronous IO then only one is required. DBMS_SQL. Since this will usually be the same tablespace as the table is being created in.com . What happens if a tablespace clause is left off of a primary key constraint clause? This results in the index that is automatically generated being placed in then users default tablespace. you couldn?t recover. You are using hot backup without being in archivelog mode. 115. However. when the constraint was disabled the index was dropped and the information is gone. What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause? The index is created in the user?s default tablespace and all sizing information is lost.SQL or CAT*. Oracle doesn?t store this information as a part of the constraint definition. These can be viewed as extra credit but aren?t part of the answer. if the system is not capable of asynchronous IO then up to twice the number of disks used by Oracle number of DB writers should be specified by use of the db_writers initialization parameter. 114.SQL series of SQL procedures. 113. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 111. 110. 17 DBMS_UTILITY. but only as part of the index definition. What is the proper method for disabling and re-enabling a primary key constraint? You use the ALTER TABLE command for both. DBMS_SESSION. So no. this can cause serious performance problems. can you recover in the event of a failure? Why or why not? You can?t use hot backup without being in archivelog mode. This is bad since it makes tracking which table the constraint belongs to or what the constraint does harder. What causes the "snapshot too old" ORA-01555 error? How can this be prevented or mitigated? This is caused by large or long running transactions that have either wrapped onto their own rollback space or have had another transaction write on part of their rollback space. DBMS_OUTPUT and DBMS_SNAPSHOT. What happens if the constraint name is left out of a constraint clause? The Oracle system will use the default name of SYS_Cxxxx where xxxx is a system generated number. 112. This can be prevented or mitigated by breaking the transaction into a set of smaller transactions or increasing the size of the rollback segments and their extents. They may also try to answer with the UTL*.

120. ALL_ or USER_OBJECTS views.emp. 121.com . A user selects from a sequence and gets back two values.7 or so) then the index should be rebuilt. You can?t create a stored object with grants given through views. ---. Another way is to check the current_logins parameter in the v$sysstat view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command.emp.What is the problem? Somehow two values have been inserted into the dual table. If you have an example table.e. Or if the ratio Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. How can you determine if an index needs to be dropped and rebuilt? Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0 (i. what is the best way to get sizing data for the production table implementation? The best way is to analyze the table and then use the data provided in the DBA_TABLES view to get the average row length and other pertinent data for the calculation. How can you tell if a database object is invalid? By checking the status column of the DBA_. his select is: SELECT pk_seq.) or has a synonym that points to the object (create synonym emp for scott. but this only works against a single instance installation. greater than 0. He has the "DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on the tables he is using. 122. 119. A user is getting an ORA-00942 error yet you know you have granted them permission on the table.nextval FROM dual. The quick and dirty way is to look at the number of blocks the table is actually using and ratio the number of rows in the table to its number of blocks against the number of expected rows. 117. How can you find out how many users are currently logged into the database? How can you find their operating system id? There are several ways. depending upon whether you own or only have permission on the view or are using a DBA account. 18 116.) 118. single column table that should only have one value in it. A developer is trying to create a view and the database won?t let him. what is the problem? You need to verify the developer has direct grants on all tables used in the view. instead of select empid from emp. One is to look at the v$session or v$process views. what else should you check? You need to check that the user has specified the full name of the object (select empid from scott. This table is a single row.

Another method. although it is hard to document and isn?t always portable is to use the return/linefeed as a part of a quoted string.3. 124. 123. For passing in variables the numbers 1-8 can be used (&1. You want to use SQL to build SQL. 127. You want to group the following set of select returns.) and that you need to concatenate using the ?||? the values selected from the database. 19 BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.." . place the ampersanded variable in the code itself: "select * from dba_tables where owner=&owner_name. item_no The only column that can be grouped on is the "item_no" column. You want to include a carriage return/linefeed in your output from a SQL script. how can you do this? The best method is to use the CHR() function (CHR(10) is a return/linefeed) and the concatenation function "||". How can you call a PL/SQL procedure from SQL? By use of the EXECUTE (short form EXEC) command. 128.. 126.. &2. spool off Essentially you are looking to see that they know to include a command (in this case DROP USER. min(sum_of_cost). How do you execute a host operating system command from within SQL? By use of the exclamation point "!" (in UNIX and some other OS) or the HOST (HO) command. What SQLPlus command is used to format output from a select? This is best done with the COLUMN command.sql select ?drop user ?||username||? cascade.? from dba_users where username not in ("SYS?. 130.&8) to pass the values after the command into the SQLPLUS session. 125.CASCADE. a single ampersand will cause a reprompt for the value unless an ACCEPT statement is used to get the value from the user. An example would be: set lines 90 pages 0 termout off feedback off verify off spool drop_all.. what can you group on? Max(sum_of_cost). To be prompted for a specific variable. the rest have aggregate functions associated with them. count(item_no). what is this called and give an example This is called dynamic SQL.?SYSTEM?). 129. How can variables be passed to a SQL routine? By use of the & symbol. What special Oracle feature allows you to specify how the cost based system treats a SQL statement? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.. Use of double ampersands tells SQLPLUS to resubstitute the value for each subsequent use of the variable..com .

Once the explain plan table exists you run the explain plan command giving as its argument the SQL statement to be explained. What is explain plan and how is it used? The EXPLAIN PLAN command is a tool to tune SQL statements.rowid) from emp x where x. To use it you must have an explain_table generated in the user you are running the explain plan for. This can also be used to generate explain plan output.rowid > (select min(x. You are joining a local and a remote table. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. If they can give some example hints such as FIRST ROWS. the rowid column. What is the default ordering of an ORDER BY clause in a SELECT statement? Ascending 135. This is created using the utlxplan. they must all be used in the where clause. the network manager complains about the traffic involved. 134. What is a Cartesian product? A Cartesian product is the result of an unrestricted join of two or more tables. how can you reduce the network traffic? Push the processing of the remote data to the remote instance by using a view to pre-select the information for the join. For example: select rowid from emp e where e.emp_no = e. The result set of a three table Cartesian product will have x * y * z number of rows where x. 131. STAR. ALL ROWS.emp_no). What is tkprof and how is it used? The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. In the situation where multiple columns make up the proposed key. If you use a min/max function against your rowid and then select against the proposed primary key you can squeeze out the rowids of the duplicate rows pretty quick. 20 The COST based system allows the use of HINTs to control the optimizer path selection. The Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.sql script. 132. This will result in only the data required for the join being sent across. y. You want to determine the location of identical rows in a table before attempting to place a unique index on the table. how can this be done? Oracle tables always have one guaranteed unique column. even better. USING INDEX. 133. 136.com . z correspond to the number of rows in each table involved in the join. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool.

139. This option can be shortened to TERM. 140. How do you prevent Oracle from giving you informational messages during and after a SQL statement execution? The SET options FEEDBACK and VERIFY can be set to OFF. Another indication is steadily decreasing performance with all other tuning parameters the same. REDO LOG. Setting TERMOUT OFF turns off screen output. A tablespace has a table with 30 extents in it. 143. The PAGESIZE and LINESIZE options can be shortened to PAGES and LINES. 142. 137. what should you check first? Ensure that users don?t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view. How do you prevent output from coming to the screen? The SET option TERMOUT controls output to the screen. How do you set the number of lines on a page of output? The width? The SET command in SQLPLUS is used to control the number of lines generated per page and the width of those lines. Is this bad? Why or why not. 144. Explain plans can also be run using tkprof. How do you generate file output from SQL? By use of the SPOOL command 141. 145. Multiple extents in and of themselves aren?t bad. 138. for example SET PAGESIZE 60 LINESIZE 80 will generate reports that are 60 lines long with a line width of 80 characters. 21 explain_plan table is then queried to see the execution plan of the statement.com . getting error ORA-04031. However if you also have chained rows this can hurt performance. TEMPORARY and INDEX segments. What are some indications that you need to increase the SHARED_POOL_SIZE parameter? Poor data dictionary or library cache hit ratios. ROLLBACK. DATA. How do you set up tablespaces during an Oracle installation? You should always attempt to use the Oracle Flexible Architecture standard or another partitioning scheme to ensure proper separation of SYSTEM. What is the general guideline for sizing db_block_size and db_multi_block_read for an application that does many full table scans? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. You see multiple fragments in the SYSTEM tablespace.

149. less could indicate problems. Where can you get a list of all initialization parameters for your instance? How about an indication if they are default settings or have been changed? You can look in the init. For all parameters. 146. You can increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your system. Is this bad or good? If bad -How do you correct it? If you get excessive disk sorts this is bad. 22 Oracle almost always reads in 64k chunks. What is the fastest query method for a table? Fetch by rowid 147. When should you increase copy latches? What parameters control copy latches? When you get excessive contention for the copy latches as shown by the "redo copy" latch hit ratio. how does it happen? How can you reduce it? How do you correct it? Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won?t fit in the remaining block space. If you do a comparison between pairs of readings based on some arbitrary time span.com . Describe hit ratio as it pertains to the database buffers. Generally speaking an instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over. The major sort are parameter is the SORT_AREA_SIZE parameter. If you simply take the ratio of existing parameters this will be a cumulative value since the database started. Discuss row chaining. A value greater than 80-90% is good. look in the v$parameter view. 150. 151. This results in the row chaining to another block. It can be reduced by setting the storage Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What is the difference between instantaneous and cumulative hit ratio and which should be used for tuning? 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 disks. The two should have a product equal to 64 or a multiple of 64. this is the instantaneous ratio for that time span. their value and whether or not the current value is the default value. This indicates you need to tune the sort area parameters in the initialization files. When looking at v$sysstat you see that sorts (disk) is high.ora file for an indication of manually set parameters. 148.

What can cause a high value for recursive calls? How can this be fixed? A high value for recursive calls is cause by improper cursor usage. then it is fragmented. It can be corrected by export and import of the effected table. 159. excessive dynamic space management actions. the "class" column tells you with what.1. no. You need to determine the cause and correct it By either relinking applications to hold cursors. You see the following on a status report: redo log space requests 23 redo log space wait time 0 Is this something to worry about? What if redo log space wait time is high? How can you fix this? Since the wait time is zero.0 to 7. 155. drop and import of the tablespace contents may be the only way to reclaim non-contiguous free space. If you see contention for library caches how can you fix it? Increase the size of the shared pool. If the wait time was high it might indicate a need for more or larger redo logs. You need to check the v$waitstat view to see what areas are causing the problem. 156. 23 parameters on the table to appropriate values.7. 158. If the free space isn?t contiguous then export. UNDO is rollback segments. The ts# parameter corresponds to the ts# value found in the ts$ SYS table. use Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. If you see statistics that deal with "undo" what are they really talking about? Rollback segments and associated structures. 153. How can you tell if a tablespace has excessive fragmentation? If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files. 152. When looking at the estat events report you see that you are getting busy buffer waits. In version 7. Is this bad? How can you find what is causing it? Buffer busy waits could indicate contention in redo.3 only) In Oracle 7. 154. If a tablespace shows excessive fragmentation what are some methods to defragment the tablespace? (7. DATA is data base buffers.2 The use of the 'alter session set events 'immediate trace name coalesce level ts#'.2 and 7. and or excessive statement re-parses.? is best.3 the ?alter tablespace coalesce. The value of the "count" column tells where the problem is. 157. rollback or data blocks.? command is the easiest way to defragment contiguous free space fragmentation. If a tablespace has a default pctincrease of zero what will this cause (in relationship to the smon process)? The SMON process won?t automatically coalesce its free space fragments.com .

In a system with an average of 40 concurrent users you get the following from a query on rollback extents: ROLLBACK CUR EXTENTS --------------------. is this a problem? How can it be fixed if it is a problem? A large number of small shrinks indicates a need to increase the size of the rollback segment extents. You can look at the average transaction size in the same view to get the information on transaction size. it can even improve performance since Oracle won?t have to create a new extent when a user needs one. 24 proper space management techniques (proper storage and sizing) or ensure repeat queries are placed in packages for proper reuse.8 in the estat library cache report is this a problem? If so. how do you fix it? This indicate that the shared pool may be too small. 163. 161.-------------------------- R01 11 R02 8 R03 12 R04 9 SYSTEM 4 You have room for each to grow by 20 more extents each. If you see the value for reloads is high in the estat library cache report is this a matter for concern? Yes. Ideally you should have no shrinks or a small number of large shrinks. You have 40 extents showing and an average of 40 concurrent users. If you see a pin hit ratio of less than 0.com . Since there is plenty of room to grow no action is needed. 160. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. You look at the dba_rollback_segs view and see that you have a large number of wraps is this a problem? A large number of wraps indicates that your extent size for your rollback segments are probably too small. In fact. you should strive for zero reloads if possible. You look at the dba_rollback_segs view and see that there is a large number of shrinks and they are of relatively small size. 162. Is this a problem? As long as they are all the same size this isn?t a problem. To fix this just increase the size of the extents and adjust optimal accordingly. Is there a problem? Should you take any action? No there is not a problem. 164. Increase the size of your extents to reduce the number of wraps. Increase the shared pool size. If you see excessive reloads then increase the size of the shared pool. 165. You see multiple extents in the temporary tablespace.

ORA file. How do you set up your tablespace on installation? The answer here should show an understanding of separation of redo and rollback. what should you check first to determine if there is a problem? Check to make sure that the archiver isn?t stuck. OFA stands for Optimal Flexible Architecture. data and indexes and isolation os SYSTEM tables from other tables. An example would be to specify that at least 7 disks should be used for an Oracle installation so that you can place SYSTEM tablespace on one.ORA.ORA file 171. When configuring SQLNET on the server what files must be set up? INITIALIZATION file. SQLNET. As long as they have a logical plan for combining or further separation more or less disks can be specified. If archive logging is turned on during install a large number of logs will be created. You have just started a new instance with a large SGA on a busy existing server.com . Performance is terrible.ORA 172. They should indicate how they will handle archive logs and exports as well. What must be installed with ODBC on the client in order for it to work with Oracle? SQLNET and PROTOCOL (for example: TCPIP adapter) layers of the transport programs. What should be done prior to installing Oracle (for the OS and the disks)? Adjust kernel parameters or OS tuning parameters in accordance with installation guide. 170. 173. TNSNAMES. When configuring SQLNET on the client what files need to be set up? SQLNET. ROLLBACK tablespace on another and still have two for DATA and INDEXES. TNSNAMES. redo logs on two (mirrored redo logs) the TEMPORARY tablespace on another. You have been waiting an hour for the initialization script to finish. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Be sure enough contiguous disk space is available. 25 166. 167. Define OFA. You have installed Oracle and you are now setting up the actual instance. what should you check for? The first thing to check with a large SGA is that it isn?t being swapped out. It is a method of placing directories and files in an Oracle system so that you get the maximum flexibility for future tuning and file placement. 169. This can fill up your archive log destination causing Oracle to stop to wait for more space. 168.

How many control files should you have? Where should they be located? At least 2 on separate disk spindles. 180. if they have more than just a few tables. It is used to show the entities and relationships for a database logical model. When should the default values for Oracle initialization parameters be used as is? Never 175. 181. neither side is a "may" both are "must") as this can result in it not being Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. uniform IO and access requirements).com . 176. 177. Why are recursive relationships bad? How do you resolve them? A recursive relationship (one where a table relates to itself) is bad when it is a hard relationship (i. 178. Usually some entities will be denormalized in the logical to physical transfer process. How many disks should you have assuming standard layout for SYSTEM. Is the following statement true or false:"All relational databases must be in third normal form" Why or why not? False. 26 174. While 3NF is good for logical design most databases. What OS user should be used for the first part of an Oracle installation (on UNIX)? You must use root first. Be sure they say on separate disks. What is an ERD? An ERD is an Entity-Relationship-Diagram. 175. not just file systems. USER. TEMP and ROLLBACK tablespaces? At least 7. see disk configuration answer above. will not perform well using full 3NF. You have a simple application with no "hot" tables (i.e.e. How many redo logs should you have and how should they be configured for maximum recoverability? You should have at least three groups of two redo logs with the two logs each on a separate disk spindle (mirrored by Oracle). Describe third normal form? In third normal form all attributes in an entity are related to the primary key and only to the primary key 179. The redo logs should not be on raw devices on UNIX if it can be avoided.

can't get err txt. What does a hard one-to-one relationship mean (one where the relationship on both ends is "must")? This means the two entities should probably be made into one entity. How should a many-to-many relationship be handled? By adding an intersection entity table 184. When should you consider denormalization? Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity. 27 possible to put in a top or perhaps a bottom of the table (for example in the EMPLOYEE table you couldn?t put in the PRESIDENT of the company because he has no boss. What is an artificial (derived) primary key? When should an artificial (or derived) primary key be used? A derived key comes from a sequence. For example.com . 187. dbwr and lgwr. 186.dbf file. pmon. or the junior janitor because he has no subordinates). See Servr Msgs & Codes Manual) What could the problem be? The instance name is probably incorrect in their connection string. These type of relationships are usually resolved by adding a small intersection entity. Any answer that has them using their operating system process showing feature to check for these is acceptable. 183. these will be smon. 189. 188. 185. Usually it is used when a concatenated key becomes too cumbersome to use as a foreign key. 182. Users from the PC clients are getting messages indicating : ORA-06114: (Cnct err. How can you determine if the SQLNET process is running for SQLNET V1? How about V2? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Users from the PC clients are getting the following error stack: ERROR: ORA-01034: ORACLE not available ORA-07318: smsget: open error when opening sgadef. on UNIX a ps -ef|grep dbwr will show what instances are up. restart the instance. How can you determine if an Oracle instance is up from the operating system level? There are several base Oracle processes that will be running on multi-user operating systems. HP-UX Error: 2: No such file or directory What is the probable cause? The Oracle instance is shutdown that they are trying to access.

you must check the alert. Connect internal only. 191. What is the problem? Check the dba_tablespaces view for the value of pct_increase for the tablespaces. 195. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.log file for this information. even though you know several have large chunks of contiguous free extents. you will have to rebuild the control file to increase it before proceeding. Where would you look to find out if a redo log was corrupted assuming you are using Oracle mirrored redo logs? There is no message that comes to the SQLDBA or SRVMGR programs during startup in this situation. If the MAX_DATAFILES is set to low. Users aren?t being allowed on the system. You look at your fragmentation report and see that smon hasn?t coalesced any of you tablespaces. You attempt to add a datafile and get: ORA-01118: cannot add anymore datafiles: limit of 40 exceeded What is the problem and how can you fix it? When the database was created the db_files parameter in the initialization file was set to 40. 192. up to the value of MAX_DATAFILES as specified at database creation. It is located in the directory specified by the background_dump_dest parameter in the v$parameter table.ora log. What file will give you Oracle instance status information? Where is it located? The alert. until freed What is the problem? The archive destination is probably full. Your users get the following error: ORA-00055 maximum number of DML locks exceeded What is the problem and how do you fix it? The number of DML Locks is set by the initialization parameter DML_LOCKS. Increase the value of DML_LOCKS. 193. For SQLNET V2 check for the presence of the LISTENER process(s) or you can issue the command "lsnrctl status". 28 For SQLNET V1 check for the existence of the orasrv process. smon will not coalesce their free space. backup the archive logs and remove them and the archiver will re-start.com . You can shutdown and reset this to a higher value. If pct_increase is zero. If this value is set to low (which it is by default) you will get this error. other protocols have similar command formats. The following message is received: ORA-00257 archiver is stuck. If you are sure that this is just a temporary problem. You can use the command "tcpctl status" to get a full status of the V1 TCPIP server. 190 . you can have them wait and then try again later and the error should clear. 194.

MAXLOGMEMBERS.) RECOVER DATABASE USING BACKUP CONTROLFILE ALTER DATABASE OPEN RESETLOGS. 197. MAXLOGHISTORY.. and settings for MAXLOGFILES. Use of Meterialized view:- Expensive operations such as joins and aggregations do not need to be reexecuted. You can also index and partition the Materialized view table like other tables to improve performance of queries executed aginst them. the server transforms the query to reference the view rather than the base tables. MAXDATAFILES for the database to use the command. If the query is astisfied with data in a Meterialized view.. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. However. 198.. What is an Oracle instance? Overview of an Oracle Instance Every running Oracle database is associated with an Oracle instance. It uses a query as the bases and the query is executated at the time the view is created and the results are stored in a table.. If no backup of the control file is available then the following will be required: CONNECT INTERNAL STARTUP NOMOUNT CREATE CONTROL FILE . they can use that to recover as well.. What are materialized views? when are they used? Materialized view is like a view but stores both definition of a view plus the rows resulting from execution of the view. logfiles. they will need to know all of the datafiles. You can define the Materialized view with the same storage parametes as any other table and place it in any tablespace of your choice. He has corrupted all of the control files while playing with the ALTER DATABASE BACKUP CONTROLFILE command. When a database is started on a database server (regardless of the type of computer).. then restart If they have a recent output file from the ALTER DATABASE BACKUP CONTROL FILE TO TRACE. 29 196. (bring read-only tablespaces back online) Shutdown and backup the system. You get a call from you backup DBA while you are on vacation.. command..com . OFFLINE. What do you do? As long as all datafiles are safe and he was successful with the BACKUP controlfile command you can do the following: CONNECT INTERNAL STARTUP MOUNT (Take any read-only tablespaces offline before next step ALTER DATABASE DATAFILE .

Referential integrity Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 30 Oracle allocates a memory area called the System Global Area (SGA) and starts one or more Oracle processes. The memory and processes of an instance manage the associated database’s data efficiently and serve the one or multiple users of the database. a view is not allocated any storage space. What is a view? A view is a tailored presentation of the data contained in one or more tables (or other views). users cannot access the information that it contains. Unlike a table. Normal users do not have control over the current status of an Oracle database. The Instance and the Database After starting an instance. Only the database administrator can start up an instance and open the database.com . If a database is open. Views are very powerful because they allow you to tailor the presentation of data to different types of users. What is referential integrity? Rules governing the relationships between primary keys and foreign keys of tables within a relational database that determine data consistency. each accessing its own physical database. Views are often used to: • provide an additional level of table security by restricting access to a predetermined set of rows and/or columns of a table • hide data complexity • simplify commands for the user • present the data in a different perspective from that of the base table • isolate applications from changes in definitions of base tables • express a query that cannot be expressed without using a view 200. Security for database startup and shutdown is controlled via connections to Oracle with administrator privileges. Multiple instances can execute concurrently on the same computer. These tables are called base tables. a view is defined by a query that extracts or derives data from the tables the view references. This is called mounting the database. rather. the Oracle Parallel Server allows multiple instances to mount a single database. The database is then ready to be opened. In clustered and massively parallel systems (MPP). This combination of the SGA and the Oracle processes is called an Oracle instance. which makes it accessible to authorized users. nor does a view actually contain data. Views present a different representation of the data that resides within the base tables. Oracle associates the instance with the specified database. 199 . the database administrator can shut down the database so that it is closed. When a database is closed.

sql %rowcount :returns a pneumeric value stating no. WE CAN WRITE TWO CURSORS IN ONE PROGRAM WE CAN WRITE A CURSOR SPECIFYING PARAMETERS CURSOR WITH UPDATE CLAUSE IS USED TO PERFORM LOCKS ON DATA. What is a sequence? It is a database object to auto generate numbers.sql%notfound : returns a boolean value stating whether the record is not found in the cursor 4. Snapshot: A snapshot is a read-only copy of a table or a subset of a table. 2. 3. adv: 1.% found 3.% not found 4.sql % found: returns boolean value stating whether the record is found in the cursor.of rows executed in the cursor. explicit cursors—retrives multiple rows. user_tab_privs_made. 31 requires that the value of every foreign key in every table be matched by the value of a primary key in another table.% rowcount Note: DATA which is populated in the cursor is known as active data set.explicit implicit ——— attributes or properties for implicit cursor 1. 205. What is a cursor? cursor is a private sql work area used to perform manipulations on data using pl\sql. cursors are of two types 1. ************ adv: users can perform locks on th data in the cursor attributes 1.com . note: data which is populated into the cursor is known as active dataset.implicit 2. 204. they are available in tow views . 206 Name the data dictionary that stores user-defined Stored procedures? user_objects Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What is a collection of privileges? collection of privilages is role. 201.mainly used for multiple row manipulations and locking columns.sql%is open:attribute returns a boolean value stating wether the cursor is open or closed. user_tab_privs_recd 203 .% is open 2. Name the data dictionary that stores user-defined constraints? USER_CONSTRAINTS 202.

ODBC stands for open database connectivity 209. Types of Normalization: 1 NF 2 NF 3 NF BCNF 5 NF 6NF : Impossible to achieve this level of normalization 210. for Example : insert into CAR values(…) where the values to be inserted into a row of the table are listed inside the parentheses. 32 207. create synonym <synonymname> for <schemaname>. Sql*Forms allows you to add rows interactively using forms. 208. ODL loads the table from a control file and separate fixed format data file.procedures and other database objects generally when we have more than one schema and we wish to access an object of a different schema then we create synonyms for that object in the schema where we wish to access the object. SQL * Loader is much more flexible than ODL and will eventually supersede it on all systems. what is an exception ? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Dates and Characters data must be Surrounded by single quotes. items are seperated by commas.com . The Sql insert command may be used from the SQL * Plus module.<object-name> 211. Why Use Sql* Loader in Oracle Database? The Sql Loader module of the oracle database Management System loads data into an existing ORACLE table from an external files. ODL is available on all versions of ORACLE . The forms may contain default values and checks for invalid data. 3. what is a synonym ? A synonym is an alternative name for tables. There are several methods others than using SQL *Loader of inserting data into a table.It is available locally only on CMS and PCs with oracle version 5. 1. Throughout this documentation the CAR database described in Referance A is used for illustration. Explain Normalization Normalization is the techinque of designing the database with the least redundancy and duplicacy of data. 2.views.

what is trigger? Trigger is an event. or delete their values. What is a schema ? A schema is a logical collection of database objects like tables. so.before update after insert.TOO_MANY_ROWS 2) User-defined exceptions which would validate the business logic 3) unnamed system exceptions which are raised due to errors in the application code . and raises that exception with a call to RAISE_APPLICATION_ERROR.after update 2)statement level trigger before insert. triggers.. 214. In oracle there are serveral types of exceptions 1) Pre-defined exceptions like NO_DATA_FOUND. What is a co-related sub-query? It is very similar to sub-queries where the parent query is executed based on the values returned by sub-quries.before update after insert.after update 3)INSTEAD OF trigger 4)Schema level Triggers Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. but you cannot insert. for all the exceptions raised oracle fills in sqleerm and sqlcode variable which provide the error message and error code for the exception raised.NEXTVAL. etc. pkgs. You can select from pseudocolumns. but when come’s to co-related subqueries for every instance of parent query subquery is executed and based on the result of sub-query the parent query will display the record as we will have refernce of parent quries in su- queries we call these as corelated subquries. update. the programmer provides both an error number (between -20000 and -20999) and an error message.before delete. 215. but is not actually stored in the table. In this case.after delete.com . we can define co-related sub query as for every record retrival from the sub query is processed and based on result of process the parent record is displayed. Exceptions that are defined and raised in the server by the programmer. It usually has an associated database user.There has a different types of trigger are available.after delete.LEVEL 213. views. What are pseudo-columns in SQL? Provide examples? A pseudocolumn behaves like a table column. 212. 1)rowlevel trigger before insert. 33 Exception is an event that causes suspension of normal program execution.ROWID. procedures. It is used prevent the invalid entries of the data. Examples: CURRVAL.before delete. you can name these exceptions using PRAGMA EXCEPTION_INIT 4)Unnamed programmer-defined exceptions.

mention the column name after columns 218. If a particular column has to be dropped. 223. The logical data structure developed during the logical database design process is a data model or entity model. INDEX & TABLE PARTITION Index for a physical structure (b-tree) to help you query run faster. 34 5)System level Triggers 216. 217. Is there any solution to delete a particular colum in a database by sql? Alter table drop column or First mark the column unused alter table set unused column then drop it alter table drop unused columns. Relation: Mathematical term for a table. It is also a description of the structural properties that define all entries represented in a database and all the relationships that exist among them. Table partition is a method of breaking a large table into smaller tables grouped by some logical separators.com . 221. What is an oracle instance? An Oracle instance consists of the System Global Area (SGA) memory structure and the background processes used to manage a database. An instance is identified by using methods specific to each operating system. Data Control statements These are used to control the data using DCL (data control language) ex: Grant etc. A database MUST have at least two redo log files. 219. view or cursor %TYPE is used to declare a field with the same type as that of a specified table’s column. This will drop all the columns marked as unused. Redo Log: A set of files that record all changes made to an Oracle database. Log files can be multiplexed on multiple disks to ensure that they will not get lost. 222. The instance can open and use only one database at a time. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What is data Modal. %ROWTYPE & %TYPE %ROWTYPE is used to declare a record with the same types as found in the specified database table. having both index and partition will make things faster. in your case. 220.

ARCH is an Oracle background process created when you start an instance in ARCHIVE LOG MODE. some duplicated data storage is allowed. 227. Equi Join: An Equi Join (aka. Oracle ARCHiver Process. The converse of an equi join is a nonequijoin operation. The benefits are quicker data retrieval and/or a database structure that is easier for end-users. Self Join: A join in which a table is joined with itself. Join: The process of combining data from two or more tables using matching columns. 226. The steps involved are the “prepared” and “commit request” 228. Background Process: Non-user process that is created when a database instance is started. These processes are used to manage and monitor database operations. Denormalization: The opposite of data normalization (almost).com .e: colA = colB) to match rows from different tables. Performance of the buffer cache is indicated by the BCHR (Buffer Cache Hit Ratio). Two-Phase Commit: A strategy in which changes to a database are temporarily applied. Inner Join or Simple Join) is a join statement that uses an equivalency operation (i. Outer Join: Similar to the Equi Join. Natural Join. The ARCH process will archive on-line redo log files to some backup media. Buffer Cache: The portion of the SGA that holds copies of Oracle data blocks. Once it has been determined that all parts of a change can be made successfully. PMON etc. ORACLE INSTANCE Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 35 224. Missing values are filled with null values. Intersect: All distinct rows selected by both queries Minus: All distinct rows that are selected by the first SELECT statement and that are not selected in the second SELECT statement. 225. Outer Join. Types of join are Equi Join. One should check whether common columns exist in both tables before doing a natural join. 230. etc. All user processes that connect to an instance share access to the buffer cache. In a denormalized database. 229. but Oracle will also return non matched rows from the tale with the outer join operator (+). Example background processes: SMON. the changes are permanently posted to the database. Natural Join: A join statement that compares the common columns of both tables with each other. Self Join. SET OPERATIONS Union: All the distinct rows are selected by either query.

a view is defined by a query that extracts or derives data from the tables the view references. Multiple instances can execute concurrently on the same computer. When a database is started on a database server (regardless of the type of computer). The Instance and the Database After starting an instance. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. each accessing its own physical database. Only the database administrator can start up an instance and open the database. a view is not allocated any storage space. 231: What is a view? A view is a tailored presentation of the data contained in one or more tables (or other views). nor does a view actually contain data. rather. Views are very powerful because they allow you to tailor the presentation of data to different types of users. 36 Every running Oracle database is associated with an Oracle instance. In clustered and massively parallel systems (MPP). What is referential integrity? Rules governing the relationships between primary keys and foreign keys of tables within a relational database that determine data consistency. which makes it accessible to authorized users. the Oracle Parallel Server allows multiple instances to mount a single database. Views present a different representation of the data that resides within the base tables.com . Unlike a table. Referential integrity requires that the value of every foreign key in every table be matched by the value of a primary key in another table. The instance can open and use only one database at a time. Security for database startup and shutdown is controlled via connections to Oracle with administrator privileges. Views are often used to: • provide an additional level of table security by restricting access to a predetermined set of rows and/or columns of a table • hide data complexity • simplify commands for the user • present the data in a different perspective from that of the base table • isolate applications from changes in definitions of base tables • express a query that cannot be expressed without using a view 232. Oracle associates the instance with the specified database. If a database is open. Oracle allocates a memory area called the System Global Area (SGA) and starts one or more Oracle processes. The database is then ready to be opened. This combination of the SGA and the Oracle processes is called an Oracle instance. Normal users do not have control over the current status of an Oracle database. users cannot access the information that it contains. the database administrator can shut down the database so that it is closed. When a database is closed. These tables are called base tables. The memory and processes of an instance manage the associated database’s data efficiently and serve the one or multiple users of the database. This is called mounting the database.

Name the data dictionary that stores user-defined constraints? USER_CONSTRAINTS 234. procedures and other database objects generally when we have more than one schema and we wish to access an object of a different schema then we create synonyms for that object in the schema where we wish to access the object. Create synonym <synonym-name> for <schemaname. What is a synonym? A synonym is an alternative name for tables. 2) User-defined exceptions which would validate the business logic. In this case.object-name> CREATE SYNONYM EMP_CPY FOR SCOTT. DUPLICATE_ROWS_ON_INDEX. In oracle there are several types of exceptions 1) Pre-defined exceptions like NO_DATA_FOUND. TOO_MANY_ROWS. 3) Unnamed system exceptions which are raised due to errors in the application code. Types of Normalization: 1 NF 2 NF 3 NF BCNF a. the programmer provides both an error number (between -20000 and -20999) and an error message. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 236.k. and ZERO_DIVIDE.a 4 NF 5 NF 6NF : Impossible to achieve this level of normalization 235. Normalization is the technique of designing the database with the least redundancy and duplicity of data. 37 233. ODBC stands for Open DataBase Connectivity: It is used to connect the front-end with the backend (database) 234. views. Exceptions that are defined and raised in the server by the programmer.EMP. and raises that exception with a call to RAISE_APPLICATION_ERROR. You can name these exceptions using PRAGMA EXCEPTION_INIT 4) Unnamed programmer-defined exceptions. What is an exception? Exception is an event that causes suspension of normal program execution.com .

level. as follows: INSERT ALL INTO ord_item_qty (item.com .nextval from dual. amt) values (item. 237. or delete their values. but you cannot insert. price from ord_items. AUTONOMOUS TRANSACTION An autonomous transaction starts with the first sql statement of the pl/sql block and ends with a commit. These are used with sequences to retrieve the next sequence value and current sequence value. if we want to see the next value of the sequence we issue the command SQL>select abc.Name of the database to which the user is connected? select * from global_name. 238.What are pseudo-columns in SQL? A pseudocolumn behaves like a table column. qty) INTO item_sale (item.Inserting into multiple tables using a single statement is possible: Table ord_item_qty has the following data: ITEM QTY PRICE ——————– ———- apples 10 2 oranges 15 1. ex: rownum. 241. 38 For all the exceptions raised. 240.currval from dual. but is not actually stored in the table. Oracle fills in SQLERRM and SQLCODE variable which provide the error message and error code for the exception raised. qty) values (item. rowid. nextval etc Suppose abc is the sequence name if i want to see the currval of the sequence we issue the sql statement SQL> select abc. qty. update. How can we know the user id from which we have logged into Oracle? In SQL*Plus. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. qty * price) SELECT item.5 We now insert into two other tables. currval. You can select from pseudocolumns. It starts within the context of an another transaction called parent transaction and independent of it(parent transaction). ORD_ITEM_QTY (this has columns ITEM and QTY) and ITEM_SALE (this has columns ITEM and AMT). enter the command “show user” 239.

Only the last transaction that has error will be rolled back only if there is no error handler. the autonomous transaction has no effect on it.city) manager(ename.employee where employee. 39 To make a transaction autonomous u have to declare PRAGMA AUTONOMOUS_TRANSACTION at the beginning.ename = m1.manager m1.shift) where ename=employee name cname=company name jdate=date of join city in employee table means city in which employee resides city in company table mean city in which company presents mname=manager name shift means the time in which employee works now please give the queries for the following tasks 1.cname. This is the answer for your second query… select distinct m1.mname) employee(ename.city = q1.ename. of using PRAGMA AUTONOMOUS_TRANSACTION is that whether the transaction made by the parent may be rolled back due to some error.ename.(select distinct managername.city) emp_shift(ename.managername) q1 where e1. 242.city = ‘bombay’) q1 where m1.ename and m1.managername.com . What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.ename = q1.ec. Suppose there is any error in autonomous transaction then what would happen ? Don’t worry It will save all the transactions just before the error occurred.city from manager. (select distinct ename from employee where employee.city from employee e1.ename and e1.ename = manager. The following are table names followed by column names present in it emp_company(ename.manager m1.e1.city and m1.managername = q1.jdate) company(cname.give the salary of manager 0f employees living in city ‘bombay’ This is the answer for your first query… select m1.mname.salary.give the names of employees living in the same city where their manager is also living 2. The main adv.salary from emp_company ec. 243.mname = ec.

There is a background process ARCH which keep on taking ARCHIVE of online redo files in some backup space. what is the use of rollback segment in oracle. 247. Oracle doesn’t store this information as a part of the constraint definition. The usual fix involves either use of views or temporary tables so the database is selecting from one while updating the other. 249. 245. A table is created with a primary key and some other constrains such as not null. function and anonymous pl/sql block. 246.date in data types in oracle. Candidate should mention use of DECLARE statement.com . Describe the difference between a procedure. All update delete. Is the same constraints applicable to the copied table or not When any other table is created using other table.varchar. constraints are not copied only table structure and data would be copied. The %TYPE associates a variable with a single column type.number. We can recover undo those changes by using redo log files. a function must return a value while a procedure doesn’t have to.check etc. 248. but only as part of the index definition. what r the advantages and disadvantages of using an integer in oracle 10g INTEGER Datatype in Oracle is an alias for Number(38) so there is no difference in them just Integer have No scale and No decimal.varchar2. What is a mutating table error and how can you get around it? This happens with triggers. when we delete some record in the table where it is stored. 250. 40 The index is created in the user’s default tablespace and all sizing information is lost. Describe the use of %ROWTYPE and %TYPE in PL/SQL %ROWTYPE allows you to associate a variable with an entire table row. or manipulation information is stored in rollback segment in rollback files that are multiplexed into different disks. so that latter we can rollback in to it. If you delete any record it would be temporarily deleted from database table. Usually we use char. when you commit the transaction it would be permanently deleted from database table.if the same table is copied into another table with other name. What packages (if any) has Oracle provided for use by developers? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. It occurs because the trigger is trying to update a row it is currently using. when the constraint was disabled the index was dropped and the information is gone 244.

UTL_FILE. but not really what was asked. If not specified in this order will result in the final return being done twice because of the way the %NOTFOUND is handled by PL/SQL. 252. These are especially useful for the WHEN OTHERS exception. In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the %NOTFOUND cursor variable in the exit when statement? Why? OPEN then FETCH then LOOP followed by the exit when. the error that occurred in the code. but this only shows errors. The DBMS_OUTPUT package can be used to show intermediate results from loops and the status of variables as the procedure is executed. The SQLERRM returns the actual error message for the last error encountered. 41 Oracle provides the DBMS_ series of packages. DBMS_ALERT. Another possible method is to just use the SHOW ERROR command. DBMS_OUTPUT. store in an error log table. How can you generate debugging output from PL/SQL? Use the DBMS_OUTPUT package. DBMS_UTILITY. 253. or RECORD. DBMS_LOCK. If they can mention a few of these and describe how they used them. even better. Give one method for transferring a table from one schema to another: Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 257. great. Describe the use of PL/SQL tables PL/SQL tables are scalar arrays that can be referenced by a binary integer. or. It must come first in a PL/SQL stand alone file if it is used.com . non-stored PL/SQL procedures. DBMS_TRANSACTION. DBMS_PIPE. What are SQLCODE and SQLERRM and why are they important for PL/SQL developers? SQLCODE returns the value of the error number for the last error encountered. if a cursor is open? Use the %ISOPEN cursor status variable. There are many which developers should be aware of such as DBMS_SQL. 251. DBMS_DDL. 254. DBMS_JOB. 256. The new package UTL_FILE can also be used. How can you find within a PL/SQL block. In Oracle 8 they will be able to be of the %ROWTYPE designation. They can be used to hold values for use in later queries or calculations. When is a declare statement needed? The DECLARE statement is used in PL/SQL anonymous blocks such as with stand alone. They can be used in exception handling to report. If they include the SQL routines provided by Oracle. 255.

how can this be done? Oracle tables always have one guaranteed unique column. 258. The default value is N.e. (On UNIX) When should more than one DB writer process be used? How many should be used? If the UNIX system being used is capable of asynchronous IO then only one is required.. the rowid column. what is the best way to get sizing data for the production table implementation? The best way is to analyze the table and then use the data provided in the DBA_TABLES View to get the average row length and other pertinent data for the calculation. The quick and dirty way is to look at the number of blocks the table is actually using and ratio the number of rows in the table to its number of blocks against the number of expected rows. the error is ignored and the tables data will be inserted.3. greater than 0. AS SELECT. If you use a min/max function against your rowid and then select against the proposed primary key you can squeeze out the rowids of the duplicate rows pretty quick.. 259. 262.0 (i. or COPY. if the system is not capable of asynchronous IO then up to twice the number of disks used by Oracle number of DB writers should be specified by use of the db_writers initialization parameter. If it is specified.7 or so) then the index should be rebuilt. 261. for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys. For example: Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What is the purpose of the IMPORT option IGNORE? What is default setting for it ? The IMPORT IGNORE option tells import to ignore "already exists" errors. 260. What is the proper method for disabling and re-enabling a primary key constraint? You use the ALTER TABLE command for both.com . If you have an example table. Or if the ratio BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0. 42 There are several possible methods. 263. However. How can you determine if an index needs to be dropped and rebuilt? Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn’t near 1. CREATE TABLE. export-import. If it is not specified the tables that already exist will be skipped. You want to determine the location of identical rows in a table before attempting to place a unique index on the table.

z correspond to the number of rows in each table involved in the join. their value and whether or not the current value is the default value.emp_no).sql script. What is tkprof and how is it used? The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. If you see contention for library caches how can you fix it? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 267. In the situation where multiple columns make up the proposed key. Where can you get a list of all initialization parameters for your instance? How about an indication if they are default settings or have been changed? You can look in the init. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool.rowid) From emp_cpy x Where x. 268. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. 266. What is explain plan and how is it used? The EXPLAIN PLAN command is a tool to tune SQL statements. y. look in the v$parameter view. The result set of a three table Cartesian product will have x * y * z number of rows where x. It can be corrected by export and import of the effected table.ora file for an indication of manually set parameters. Once the explain plan table exists you run the explain plan command giving as its argument the SQL statement to be explained. What is a Cartesian product? A Cartesian product is the result of an unrestricted join of two or more tables.rowid > (select min (x. For all parameters. 265. This results in the row chaining to another block. Discuss Row-Chaining. 264.com . 43 Select rowid from emp_cpy e Where e. It can be reduced by setting the storage parameters on the table to appropriate values. how does it happen? How can you reduce it? How do you correct it? Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won’t fit in the remaining block space. they must all be used in the where clause. This can also be used to generate explain plan output. This is created using the utlxplan. To use it you must have an explain_table generated in the user you are running the explain plan for. The explain_plan table is then queried to see the execution plan of the statement. 269.emp_no = e. Explain plans can also be run using tkprof.

272. How many control files should you have? Where should they be located? At least 2 on separate disk spindles. If you see statistics that deal with "undo" what are they really talking about? Rollback segments and associated structures. You see multiple extents in the temporary tablespace. Usually some entities will be denormalized in the logical to physical transfer process. if they have more than just a few tables. 274. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. will not perform well using full 3NF. 275. 44 Increase the size of the shared pool. Describe third normal form? In third normal form all attributes in an entity are related to the primary key and only to the primary key 277. While 3NF is good for logical design most databases. it can even improve performance since Oracle won’t have to create a new extent when a user needs one.com . Is this a problem? As long as they are all the same size this isn’t a problem. 276. Be sure they say on separate disks. not just file systems. 273. If a tablespace has a default pctincrease of zero what will this cause (in relationship to the smon process)? The SMON process won’t automatically coalesce its free space fragments. 270. How many redo logs should you have and how should they be configured for maximum recoverability? You should have at least three groups of two redo logs with the two logs each on a separate disk spindle (mirrored by Oracle). In fact. 271. then it is fragmented. The redo logs should not be on raw devices on UNIX if it can be avoided. How can you tell if a tablespace has excessive fragmentation? If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files. Is the following statement true or false: "All relational databases must be in third normal form" Why or why not? False.

or the junior janitor because he has no subordinates).e. Change SQL prompt name SQL> set sqlprompt “Manimara > “ Manimara > 285. Why are recursive relationships bad? How do you resolve them? A recursive relationship (one where a table relates to itself) is bad when it is a hard relationship (i. These type of relationships are usually resolved by adding a small intersection entity. 279. What is an ERD? An ERD is an Entity-Relationship-Diagram. 280. 284. 283.dv). or SQL> delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from table_name tb where ta. Usually it is used when a concatenated key becomes too cumbersome to use as a foreign key. Switch to DOS prompt SQL> host 286. neither side is a "may" both are "must") as this can result in it not being possible to put in a top or perhaps a bottom of the table (for example in the EMPLOYEE table you couldn’t put in the PRESIDENT of the company because he has no boss.dv=tb. How do I eliminate the duplicate rows ? SQL> delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name). What is an artificial (derived) primary key? When should an artificial (or derived) primary key be used? A derived key comes from a sequence.com . 281. It is used to show the entities and relationships for a database logical model. When should you consider denormalization? Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity. How should a many-to-many relationship be handled? By adding an intersection entity table 282. 45 278. What does a hard one-to-one relationship mean (one where the relationship on both ends is "must")? This means the two entities should probably be made into one entity. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.

Display the records between two range select rownum.ename = b. Output: 1 Scott 2 Millor 3 Jiyo 4 Smith 6. ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start). Table Emp Empno Ename 101 Scott 102 Jiyo 103 Millor 104 Jiyo 105 Smith delete ename from emp a where rowid < ( select min(rowid) from emp b where a. instead of blank space. 0)). number or char or date Nvl(comm. Enter value for upto: 10 Enter value for Start: 7 ROWNUM EMPNO ENAME --------.'NA') from emp. Empno Ename 101 Scott 102 Millor 103 Jiyo 104 Smith 287. Output : Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. I know the nvl function only allows the same data type(ie.ename). ename from emp. empno.).com . if commission is null then the text “Not Applicable” want to display.--------. How do I display row number with records? To achive this use rownum pseudocolumn with query. The output like.---------- 1 7782 CLARK 2 7788 SCOTT 3 7839 KING 4 7844 TURNER 288. like SQL> select rownum. 46 Example. How do I write the query? SQL> select nvl(to_char(comm.

290. (to_char(to_date(sal.'NA') ----------------------- NA 300 500 NA 1400 NA NA 289. SQL%ROWCOUNT. is called as Cursor. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. cursor_name%ISOPEN 291. : 2. 'jsp')) from emp. Enter value for n: 2 SAL --------- 3700 293. because oracle automatically closed the implicit cursor after executing SQL statements. Here SQL%ISOPEN is false. PL/SQL declares all implicit cursors. 294. cursor_name%NOTFOUND. For queries that returning more than one row.sal)) FROM EMP B WHERE a. the cursor needs to be explicitly declared. Implicit Cursor attributes Same as explicit cursor but prefixed by the word SQL SQL%Found. PL/SQL construct to identify each and every work are used. For SQL queries returning a single row.'j'). Display the number value in Words SQL> select sal.com . 292. Oracle cursor : Implicit & Explicit cursors Oracle uses work areas called private SQL areas to create SQL statements. Find out nth highest salary from emp table SELECT DISTINCT (a. All are Boolean attributes. the output like. SQL%NOTFOUND. Explicit Cursor attributes There are four cursor attributes used in Oracle cursor_name%Found. cursor_name%ROWCOUNT. 47 NVL(TO_CHAR(COMM). SQL%ISOPEN Tips : 1.sal).sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal<=b. To view installed Oracle version information SQL> select banner from v$version.

48

SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP'))
--------- -----------------------------------------------------
800 eight hundred
1600 one thousand six hundred
1250 one thousand two hundred fifty
If you want to add some text like,
Rs. Three Thousand only.
SQL> select sal "Salary ",
(' Rs. '|| (to_char(to_date(sal,'j'), 'Jsp'))|| ' only.'))
"Sal in Words" from emp
/
Salary Sal in Words
------- ------------------------------------------------------
800 Rs. Eight Hundred only.
1600 Rs. One Thousand Six Hundred only.
1250 Rs. One Thousand Two Hundred Fifty only.

295. Display Odd/ Even number of records
Odd number of records:
select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
1
3
5
Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
2
4
6

296. Which date function returns number value?
months_between

297. What are PL/SQL Cursor Exceptions?
CURSOR_ALREADY_OPEN, INVALID_CURSOR

298. Other way to replace query result null value with a text
SQL> Set NULL ‘N/A’
to reset SQL> Set NULL ‘’

289. What are the more common pseudo-columns?
SYSDATE, USER , UID, CURVAL, NEXTVAL, ROWID, ROWNUM

290. What is the output of SIGN function?
1 for positive value, 0 for Zero, -1 for Negative value.

291. What is the maximum number of triggers, can apply to a single table?

12 triggers.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

49

292. Explain the difference between a hot backup and a cold backup and the
benefits associated with each.

A hot backup is basically taking a backup of the database while it is still up and
running and it must be in archive log mode. A cold backup is taking a backup of the
database while it is shut down and does not require being in archive log mode. The
benefit of taking a hot backup is that the database is still available for use while the
backup is occurring and you can recover the database to any point in time. The
benefit of taking a cold backup is that it is typically easier to administer the backup
and recovery process. In addition, since you are taking cold backups the database
does not require being in archive log mode and thus there will be a slight
performance gain as the database is not cutting archive logs to disk.

293. You have just had to restore from backup and do not have any control files.
How would you go about bringing up this database?

I would create a text based backup control file, stipulating where on disk all the data
files where and then issue the recover command with the using backup control file
clause.

294. How do you switch from an init.ora file to a spfile?

Issue the create spfile from pfile command.

295. Explain the difference between a data block, an extent and a segment.

A data block is the smallest unit of logical storage for a database object. As objects
grow they take chunks of additional storage that are composed of contiguous data
blocks. These groupings of contiguous data blocks are called extents. All the extents
that an object takes when grouped together are considered the segment of the
database object.

296. Give the reasoning behind using an index.

Faster access to data blocks in a table.

297. Give the two types of tables involved in producing a star schema and the
type of data they hold.

Fact tables and dimension tables. A fact table contains measurements while
dimension tables will contain data that will help describe the fact tables.

298. What type of index should you use on a fact table? A Bitmap index.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

50

299. A table is classified as a parent table and you want to drop and re-create it. How
would you do this without affecting the children tables?

Disable the foreign key constraint to the parent, drop the table, re-create the table,
enable the foreign key constraint.

300. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode
and the benefits and disadvantages to each.

ARCHIVELOG mode is a mode that you can put the database in for creating a
backup of all transactions that have occurred in the database so that you can
recover to any point in time. NOARCHIVELOG mode is basically the absence of
ARCHIVELOG mode and has the disadvantage of not being able to recover to any
point in time. NOARCHIVELOG mode does have the advantage of not having to write
transactions to an archive log and thus increases the performance of the database
slightly.

301. How would you determine the time zone under which a database was
operating?

SQL>select DBTIMEZONE from dual;

302. Explain the use of setting GLOBAL_NAMES equal to TRUE.

Setting GLOBAL_NAMES dictates how you might connect to a database. This variable
is either TRUE or FALSE and if it is set to TRUE it enforces database links to have the
same name as the remote database to which they are linking.

303. What command would you use to encrypt a PL/SQL application?

WRAP

304. Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.

A function and procedure are the same in that they are intended to be a collection
of PL/SQL code that carries a single task. While a procedure does not have to return
any values to the calling application, a function will return a single value. A package
on the other hand is a collection of functions and procedures that are grouped
together based on their commonality to a business function or application.

305. Explain the use of table functions.

Table functions are designed to return a set of rows through PL/SQL logic but are
intended to be used as a normal table or view in a SQL statement. They are also used
to pipeline information in an ETL process.

306. Explain materialized views and how they are used.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

How do you add a data file to a tablespace? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. They are typically used in data warehouse or decision support systems. grouped. When a user process fails. When creating a user. 314. 313. What background process refreshes materialized views? The Job Queue Processes. 310. What does coalescing a tablespace do? Coalescing is only valid for dictionary-managed tablespaces and de-fragments space by combining neighboring free extents into large single extents. what permissions must you grant to allow them to connect to the database? Grant the CONNECT to the user. Name a tablespace automatically created when you create a database. 309. 311. Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database. or aggregated from base tables. What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace? A temporary tablespace is used for temporary objects such as sort structures while permanent tablespaces are used to store those objects meant to be used as the true objects of the database. The SYSTEM tablespace. 308. Describe what redo logs are. 307. 51 Materialized views are objects that are reduced sets of information that have been summarized. what background process cleans up after it? PMON—Process Monitor 308. 312.com . How would you force a log switch? ALTER SYSTEM SWITCH LOGFILE.

Explain what partitioning is and what its benefit is. 316. Partitioning is a method of taking large tables and indexes and splitting them into smaller. You have just compiled a PL/SQL package but got errors. more manageable pieces. 52 ALTER TABLESPACE <tablespace_name> ADD DATAFILE <datafile_name> SIZE <size> 315. How can you rebuild an index? ALTER INDEX <index_name> REBUILD. What is the difference between the SQL*Loader and IMPORT utilities? These two Oracle utilities are used for loading data into the database. 319. How can you enable a trace for a session? Use the DBMS_SESSION. Which of the following statements is true about implicit cursors? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com . 323. What view would you use to look at the size of a data file? DBA_DATA_FILES 317. What view would you use to determine free space in a tablespace? DBA_FREE_SPACE 318. 324. how would you view the errors? SHOW ERRORS 321. The difference is that the import utility relies on the data being produced by another Oracle utility EXPORT while the SQL*Loader utility allows data to be loaded that has been produced by other utilities from different data sources just so long as it conforms to ASCII formatted or delimited files. How do you resize a data file? ALTER DATABASE DATAFILE <datafile_name> RESIZE <new_size>. 320. 322. How can you gather statistics on a table? The ANALYZE command.SET_SQL_TRACE or Use ALTER SESSION SET SQL_TRACE = TRUE.

END LOOP 20. 3. which of the following would cause an infinite loop to occur in a simple loop? 18. A developer would like to use referential datatype declaration on a variable. cursor action_cursor is b. LOOP 19. and LNAME. 330. Look up datatype for EMPLOYEE column on LASTNAME table and use that. Implicit cursors are used for SQL statements that are not named. Implicit cursors are no longer a feature in Oracle. 4. 326 . respectively. and the corresponding table and column is EMPLOYEE. e. Use employee. 11. 8. Use employee. open Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 12. The command used to open a CURSOR FOR loop is a. 53 1. Declare it to be type LONG. action c. into action_record d. How would the developer define this variable using referential datatypes? 9. There are no errors in this statement. EXIT 329. Opening and parsing of SQL statements. rate. 10. select name. from action_table. Implicit cursors are used in cursor for loops to handle data processing. IF-THEN 21. 7. Record type declaration. 325. Which line in the following statement will produce an error? a.com . %rowcount 17. %notfound 16. 2. 327.lname%type. Which of the following is not a feature of a cursor FOR loop? 5. Requires exit condition to be defined. If left out. The variable name is EMPLOYEE_LASTNAME. Which three of the following are implicit cursor attributes? 13. 6. Developers should use implicit cursors with great care. %rowtype 328. %found 14.lname%rowtype. %too_many_rows 15. Fetches records from cursor.

What happens when rows are found using a FETCH statement a. IN b. Read the following code: CREATE OR REPLACE PROCEDURE find_cpt (v_movie_id {Argument Mode} NUMBER. OUT c.cost_per_ticket > 3.cost_per_ticket > 3.75) 334. Read the following code: CREATE OR REPLACE TRIGGER update_show_gross {trigger information} BEGIN {additional code} END. END IF. It loads the current row values into variables d. It causes the cursor to close b. IN OUT 333.75) b. WHEN (new.75 c. COST_PER_TICKET.cost_per_ticket > 3. WHERE (new.com . parse d. Which trigger information will you add? a. It creates the variables to hold the current row values 332. None.5 THEN SELECT cost_per_ticket INTO v_cost_per_ticket FROM gross_receipt WHERE movie_id = v_movie_id. All that apply c. None Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 54 b. WHERE (:new. RETURN d. fetch c. It causes the cursor to open c. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs? a. The trigger code should only execute when the column. 331. END. Which mode should be used for V_COST_PER_TICKET? a. All referenced d.cost_per_ticket > 3.75) d. WHEN (:new. cursor for loops handle cursor opening implicitly. Only one b. v_cost_per_ticket {argument mode} NUMBER) IS BEGIN IF v_cost_per_ticket > 8. is greater than $3.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. END update_theater. VARIABLE :g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11). b.com . Oracle Forms trigger 336. How should you modify the function to handle this error? e. 55 335. Which set of statements will successfully invoke this function within SQL*Plus? a. VARIABLE g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11). d. Read the following code: CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER. Statement only c. you encounter the error: ORA-000: Unique constraint(SCOTT. Statement and Row b. VARIABLE g_yearly_budget NUMBER EXECUTE g_yearly_budget := GET_BUDGET(11). BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id. Read the following code CREATE OR REPLACE PROCEDURE update_theater (v_name IN VARCHAR v_theater_id IN NUMBER) IS BEGIN UPDATE theater SET name = v_name WHERE id = v_theater_id. When invoking this procedure.THEATER_NAME_UK) violated. c. 337. END. RETURN v_yearly_budget. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section. VARIABLE g_yearly_budget NUMBER :g_yearly_budget := GET_BUDGET(11). Row only d. For which trigger timing can you reference the NEW and OLD qualifiers? a.

SQLERRM c. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution. 338. c. ALTER TABLE check_theater ENABLE check_theater. END IF. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception. Only the CALCULATE_BUDGET procedure needs to be recompiled. RAISE_ERROR b.yearly_budget%TYPE. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement. Handle the error in EXCEPTION section by referencing the error code directly. 337. What effect will this have? a. END . RAISE_APPLICATION_ERROR d. Examine this database trigger CREATE OR REPLACE TRIGGER prevent_gross_modification {additional trigger information} BEGIN IF TO_CHAR(sysdate. 340. The SET_BUDGET function will be marked invalid and must be recompiled before the next execution. ALTER TRIGGER check_theater ENABLE. 56 f.30000000). d. All three procedures are marked invalid and must be recompiled. Which command can you issue to enable this trigger? a. BEGIN v_budget := get_budget(11). g. The CHECK_THEATER trigger of the THEATER table has been disabled. ENABLE check_theater. You are about to add an argument to CALCULATE_BUDGET. DY) = MON Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com . b. RAISE_SERVER_ERROR 339. Read the following code: CREATE OR REPLACE PROCEDURE calculate_budget IS v_budget studio. Which procedure can be used to create a customized error message? a. b. d. IF v_budget < 30000 THEN set_budget(11. ENABLE TRIGGER check_theater. h. c.

Add RETURN boolean right after the IS keyword. 342. END. What additional information must you add? a. 57 THEN RAISE_APPLICATION_ERROR(-20000. Which code must be added to successfully compile this function? a.Gross receipts cannot be deleted on Monday). Add RETURN right before the IS keyword. Procedure and Functions are explicitly executed. d. Altering the argument list of one of the package constructs b. AFTER DELETE ON gross_receipt c. Add RETURN boolean right before the IS keyword. Any change made to one of the package constructs c. ELSE RETURN FALSE. Add RETURN number right before the IS keyword. IF SQL%FOUND THEN RETURN TRUEl. BEFORE (gross_receipt DELETE) d. b. Any SQL statement change made to one of the package constructs d. v_new_budget IN NUMBER) IS BEGIN UPDATE studio SET yearly_budget = v_new_budget WHERE id = v_studio_id. When is a database trigger executed? a. Under which circumstance must you recompile the package body after recompiling the package specification? a. During the data manipulation statement c. END IF. END. c. This is different from a database trigger. When the transaction is committed b. This trigger must fire before each DELETE of the GROSS_RECEIPT table. Removing a local variable from the DECLARE section of one of the package constructs 343. BEFORE DELETE ON gross_receipt b. FOR EACH ROW DELETED FROM gross_receipt 341. It should fire only once for the entire DELETE statement. COMMIT.com . Examine this function: CREATE OR REPLACE FUNCTION set_budget (v_studio_id IN NUMBER. When an Oracle supplied package references the trigger Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. END IF.

347. the SELECT statement cannot be hard- coded and must be created dynamically when the function is executed. A stored function must return a value based on conditions that are determined at runtime. the construct terminates. DBMS_DDL b. c. DBMS_OUTPUT c. Which Oracle supplied package can you use to output values and messages from database triggers. Therefore. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package. Unless a GOTO statement is used to continue processing within the BEGIN section. DBMS_SYN d. d. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package. What occurs if a procedure or function terminates with failure without being handled? a. DBMS_SQL Top of Form Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 346. stored procedures and functions within SQL*Plus? a. DBMS_DML c. The construct rolls back any DML statements issued and returns the unhandled exception to the calling environment. 58 d. b. DBMS_LIST d. d.get_total_for_year.com . DBMS_DISPLAY b. For this code to be successful.v_total_seats_sold_overall := theater_pck. b. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package. DBMS_DESCRIBE 345. Any DML statements issued by the construct are committed c. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package. Any DML statements issued by the construct are still pending and can be committed or rolled back. During a data manipulation statement and when the transaction is committed 344. Examine this code BEGIN theater_pck. END. what must be true? a. Which Oracle supplied package will enable this feature? a.

4) 19.4 22.3 16.(1.1 18.4 20.4 Question 13 all the four answers are wrong .3 21.2 9. the loop do not work. The Answer to the question 5 is 4rd Choice.4 24. We do not need location (where) we need time (when). GET_BUDGET(11) ————– OR SQL>print g_yearly_budget.2 3.1 15.3. The Answer to the question 5 is 1rd Choice.2 10.3 25. procedure does not compile.1 2.1 12.4 8.2 23.3 7. 59 ANS 1. Iti’s imposible that both 3 and 4 are correct.4 13.(1.3 17.2 6.4) 5.com .1 4.(3. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. the function executed like this SQL> select get_budget(11) into :g_yearly_budget from dual.1 14.4) 11. If you are missing the END LOOP (2).

)(3.)2 . of parameters or the data type of the parameters passed to it.3.4) .)2 .3 .)3 . 356.Can functions be overloaded ? Yes.4 : 4 . This question is about Oracle triggers (not Forms). Why Create or Replace and not Drop and recreate procedures ? So that Grants are not dropped.Can you call a stored function in the constraint of a table ? No. 354 .T 9. exceptions 358.1 11.[I dont know correct answer] 12.)4 .T 6.What are the constructs of a procedure.T 5.)(1.4 : 4 . 357 .What are the various types of parameter modes in a procedure ? IN.)1 .Can you have two stored functions with the same name ? Yes.T 3. 355 .4) . but oracle triggers and Forms triggers are not the same.What are the various types of Exceptions ? User defined and Predefined Exceptions.Can we define exceptions twice in same block ? No. I tried to do and here is the revised answer list.T 7.)2 .)1 : T 4.4 : 4 .T 10. The answer to the question 13 should be 2. 349 .T 13.3 : 3 . 60 The Answer to the question 5 is 3rd Choice.Can you have two functions with the same name in a PL/SQL block ? Yes. OUT AND INOUT.What is Over Loading and what are its restrictions ? OverLoading means an object performing different functions depending upon the no. function or a package are : variables and constants cursors .3 : 3 .T 8.)2 . function or a package ? The constructs of a procedure. The 4rd (Oracle Forms trigger) is in some way correct. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.T Thanks. 352. (T means correct answer choice) 1.? : 2 . 348 .)4 .)1 .Can 2 functions have same name & input parameters but differ only by return datatype No. 350 .com .)1 : T 2. 353. 351.

com . Row and Statement Triggers. 369. 360. What is the advantage of a stored procedure over a database trigger ? We have control over the firing of a stored procedure but we have no control over the firing of a trigger. the triggers are said to be cascading. Can you pass parameters in packages ? How ? Yes.Describe Oracle database's physical and logical structure ? Physical : Data files. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. (3*2*2=12) 362. Control file. Before and After Triggers. old = NULL DELETE : new = NULL. Views.What are the values of :new and :old in Insert/Delete/Update Triggers ? INSERT : new = new value. What are mutating triggers ? A trigger giving a SELECT on the table on which the trigger is written. of statements that can be specified in a trigger statement ? One 364. old = old value UPDATE : new = new value. You can pass parameters to procedures or functions in a package. Logical : Tables. 370. What are the parts of a database trigger ? The parts of a trigger are: A triggering event or statement A trigger restriction A trigger action 361. 61 359.What are constraining triggers ? A trigger giving an Insert/Update on a table having referential integrity constraint on the triggering table. they are combination of : Insert. 363. Max = 32. Redo Log files. 368. etc. old = old value 367.What are cascading triggers? What is the maximum no of cascading triggers at a time? When a statement in a trigger body causes another trigger to be fired. Tablespaces. What is the maximum no. Delete and Update Triggers. Can views be specified in a trigger statement ? No 365.What are the various types of database triggers ? There are 12 types of triggers.

What is the use of Data Dictionary ? Used by Oracle to store information about various physical and logical Oracle structures e.Can you increase the size of datafiles ? How ? YES ____ ALTER DATABASE DATAFILE <datafile_name> RESIZE <new_size>. 376.What are the disadvantages of clusters ? The time for Insert increases. PARTLY AVAILABLE.Can Long/Long RAW be clustered ? No. OFFLINE.Can Check constraint be used for self referential integrity ? How ? Yes. 378. etc 375.An insert statement followed by a create table statement followed by rollback ? Will the rows be inserted ? YES 384. ALTER TABLESPACE <tablespace_name> ADD DATAFILE <datafile_name> SIZE <size> 372.Can you Rollback to any savepoint ?Yes.Can you increase the size of a tablespace ? How ? Yes. we can reference some other column of the same table and thus enforce self referential integrity. 382.What is the difference between unique key and primary key ? Unique key can be null. Tables. NEEDS RECOVERY and INVALID. 380.What are the advantages of clusters ? Access time reduced for joins. 377. datafiles.What is the use of Control files ? Contains pointers to locations of various data files. redo log files. Tablespaces.What are the min. 374. Primary key cannot be null. normal index ? Yes.Can you define multiple savepoints ? Yes. In the CHECK condition for a column of a table. 373.g. etc. by adding datafiles to it.com . Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. extents allocated to a rollback extent ? Two 381. 383.Can null keys be entered in cluster index.What are the states of a rollback segment ? What is the difference between partly available and needs recovery ? The various states of a rollback segment are : ONLINE. 379. 385. 62 371.

Can you use %RowCount as a parameter to a cursor ? Yes 392.What is the maximum no.How many rows will the following SQL return : Select * from emp Where rownum = 10. 388. CURSOR c1 (median IN NUMBER) IS SELECT job. then will the transaction span across different rollback segments or will it terminate ? It will terminate. No rows Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. If a transaction is very large.com . as the example below shows. 9 rows 396.Can you pass a parameter to a cursor ? Explicit cursors can take parameters.Is the query below allowed : Select sal.How many rows will the following SQL return : Select * from emp Where rownum < 10. The && operator means that the value of this variable should be the same as inputted by the user previously for this same variable. Is this for loop allowed : For x in &Start. Is the assignment given below allowed : ABC = PQR (Where ABC and PQR are records) Yes 394. of columns a table can have ? 254 387..&End Loop Yes 395. A cursor parameter can appear in a query wherever a constant can appear.What is the significance of the & and && operators in PL SQL ? The & operator means that the PL SQL block requires user input for a variable. ename Into x From emp Where ename = 'KING' (Where x is a record of Number(4) and Char(15)) Yes 393. ( ORA -01555) SNAPSHOT TOO OLD WHEN ROLLBACK SEGMENT INSUFFICIENT 389.What are the various types of RollBack Segments ? Public Available to all instances Private Available to specific instance 391. 390. and the rollback segment is not able to hold the rollback information. ename FROM emp WHERE sal > median. 63 386.

b) Object Access. last record or first record ? Last Record 401.5 as Group functions does not consider NULLS 402. What will the output be? 3 404. c) Database Action 408.A table has the following data : [[5.NULL) NULL 409. Null. Speed and Load of client server 410. a) Login attempts.What is Functional Dependency Given a relation R.What is Auditing? The database has the ability to audit all actions that take place within it.What are the disadvantages of SQL ? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 406. Result of Greatest(1. the output will be : error. Is Sysdate a system variable or a system function? System Function 403.Are views automatically updated when base tables are updated? Yes 399. attribute Y of R is functionally dependent on attribute X of R if and only if each X-value has associated with it precisely one -Y value in R 407. things to be considered ? Network Overhead (traffic).While designing in client/server what are the 2 imp. Suppose at this point we issue a rollback and again issue a nextval. a controlling process that queues request for work thus reducing the databases memory requirement and resources.Which symbol precedes the path to the table in the remote database ? @ 398.Can a trigger written for a view? No 400.If all the values from a cursor have been fetched and another fetch is issued. What is Multi Threaded Server (MTA) ? In a Single Threaded Architecture (or a dedicated server configuration) the database manager creates a separate process for each database user. Definition of relational DataBase by Dr. 10]]. Codd (IBM)? A Relational Database is a database where all data visible to the user is organized strictly as tables of data values and where all database operations work on these tables.NULL) or Least(1. 64 397. What will the average function return : 7.Consider a sequence whose currval is 1 and gets incremented by 1 by using the nextval reference we get the next number 2. However in MTA the database manager can assign multiple users (multiple user processes) to a single dispatcher (server process).com . 405.

· Use an expression in the Where Clause of the SQL. What is the effect of synonym and table name used in same Select statement ? Valid 420.What's the length of SQL integer? 32 bit length 421. But synonym can be on view.What is the difference between a view and a synonym ? Synonym is just a second name of table used for multiple link of database. What is the difference between alias and synonym? Alias is temporary and used with one query.com . 415.Can you create index on view No. and with virtual columns and with conditions. What is the result of the following SQL: Select 1 from dual UNION Select 'A' from dual.Can database trigger written on synonym of a table and if it can be then what would be the effect if original table is accessed. Reference key is the primary key of table referred by another table. Synonym is permanent and not used as alias.When to create indexes ? To be created when table is queried for less than 2% or 4% to 25% of the table rows. View can be created with many tables. 413. 417.What is the difference between foreign key and reference key? Foreign key is the key i. 419. Yes. Error 414. How can you avoid indexes? TO make index access path unavailable · Use FULL hint to optimizer for full table scan · Use INDEX or AND-EQUAL hint to optimizer to use one index or set to indexes instead of another. Can you alter synonym of view or view? No 416. 65 Disadvantages of SQL are: · Cannot drop a field · Cannot rename a field · Cannot manage memory · Procedural Language option not provided · Index on view or index on index not provided · View updation problem 411. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 412. 418. attribute which refers to another table primary key.e. database trigger would fire.

429. index is not used? <>. Oracle can manage > 100GB databases. even with large databases.. This market clout means that you are unlikely to be left in the lurch by Oracle and there are always lots of third party interfaces available. you must declare a subprogram before calling it. field +constant..Assume that there are multiple databases running on one machine. Backup and Recovery: Oracle provides industrial strength support for on-line backup and recovery and good software fault tolerance to disk failure. field || '' 426.' is NOT functions. 66 422. Multiple database support : Oracle has a superior ability to manage multiple databases within the same transaction using a two-phase commit protocol. running on more than 100 hardware platforms and 20 networking protocols. You can also do point- in-time recovery. 428. A forward declaration consists of a subprogram specification terminated by a semicolon. like '% .If any other table same as dual is created would it act similar to dual? Yes 425.What are the advantages of Oracle? Portability: Oracle is ported to more platforms than any of its competitors. The variables or expressions referenced in the parameter list of a subprogram call are actual parameters.com . dropped or altered or updated or inserted? Yes 423. For example.If content of dual is updated to some value computation takes place or not ? Yes 424 .What are actual and formal parameters ? Actual Parameters : Subprograms pass information using parameters. What is a forward declaration ? What is its use ? PL/SQL requires that you declare an identifier before using it. This declaration at the start of a subprogram is called forward declaration. Performance: Speed of a 'tuned' Oracle Database and application is quite good. For which relational operators in where clause. Can dual table be deleted. How can you switch from one to another? Changing the ORACLE_SID 427. Therefore. Market Presence: Oracle is by far the largest RDBMS vendor and spends more on R & D than most of its competitors earn in total revenue. the following procedure call lists two actual parameters Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.

can I execute his procedure even though I do not have privileges on the tables within the procedure? Yes 433. Formal Parameters : The variables declared in a subprogram specification and referenced in the subprogram body are formal parameters.5. db_block_buffers was changed from 60 to 1000 (std values are 60. If I have an execute privilege on a procedure in another users schema.com . raise_salary(emp_num. 434. What all important parameters of the init. Named. amount). What are the various types of queries? Normal Queries Sub Queries Co-related queries Nested queries Compound queries 435. 550 & 3500) shared_pool_size was changed from 3. 432.5MB to 9MB (std values are 3. 431. Mixed and Restrictions. PROCEDURE raise_salary (emp_id INTEGER. 5 & 9MB) open cursors was changed from 200 to 300 (std values are 200 & 300) db_block_size was changed from 2048 (2K) to 4096 (4K) {at the time of database creation}. 67 named emp_num and amount: Eg. The initial SGA was around 4MB when the server RAM was 32MB and the new SGA was around 13MB when the server RAM was increased to 128MB. the following procedure declares two formal parameters named emp_id and increase: Eg. triggers and packages ? Public synonyms. For example. The SQL statement for the cursor is attached dynamically at runtime from calling procedures.What are the types of Notation ? Position. 430. public synonyms. tables. 436. Which of the following is not a schema object : Indexes. What is a package cursor? A package cursor is a cursor which you declare in the package specification without an SQL statement.What is a transaction? A transaction is a set of SQL statements between any two COMMIT and ROLLBACK statements.ora are supposed to be increased if you want to increase the SGA size? In our case. increase REAL) IS current_salary REAL. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.

brings state-of-the-art programming to the Oracle database server and a variety of Oracle tools.PUTF(fileHandler.. available with Oracle7. UTL_FILE. SQL*Plus and SQL*DBA will still understand and know how to execute such scripts. This makes it much more efficient as SQL statements are not stripped off and send to the database individually. DECLARE file Handler UTL_FILE. SQL*Plus does not have a PL/SQL engine. This way you can distribute software without having to worry about exposing your proprietary algorithms and methods.How can I protect my PL/SQL source code? PL/SQL V2. END. This is done via a standalone utility that transforms the PL/SQL source code into portable binary object code (somewhat larger than the original). Unlike Oracle Forms. The language includes object oriented programming techniques such as encapsulation.2.3 is a UTL_FILE package that can read and write files.. implements a binary wrapper for PL/SQL programs to protect the source code. the maximum parsed/compiled size of a PL/SQL block is 64K and the maximum code size is 100K. 'myoutput'. You can run the following select statement to query the size of an existing package or procedure. function overloading. What is PL/SQL? PL/SQL is Oracle's Procedural Language extension to SQL.FOPEN('/home/oracle/tmp'. 68 437. Eg: CREATE OR REPLACE PROCEDURE DYNSQL AS Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Thus. 438.3 the only means of writing a file was to use DBMS_OUTPUT with the SQL*Plus SPOOL command. BEGIN fileHandler := UTL_FILE. information hiding (all but inheritance). Before Oracle 7. 'Value of func1 is %sn'. and so. SQL> select * from dba_object_size where name = 'procedure_name' 440. Just be careful. 441.'W'). there is no "decode" command available.sql oname=xxxx.FCLOSE(fileHandler). UTL_FILE. The directory you intend writing to has to be in your INIT.FILE_TYPE. func1(1)). 439.2. The syntax is: wrap iname=myscript. parameter). Is there a limit on the size of a PL/SQL block? Currently.yyy 442.ORA file (see UTL_FILE_DIR=. all your PL/SQL are send directly to the database engine for execution.com . Can one read/write files from PL/SQL? Included in Oracle 7.Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure? How? From PL/SQL V2.1 one can use the DBMS_SQL package to execute dynamic SQL statements. Is there a PL/SQL Engine in SQL*Plus? No.

Normalization – It's a technique in which we can design the DB. rc integer. 425.1trans updates emp and dep 2 trans update dep and emp 428. rc := DBMS_SQL. 2NF-Functional dependencies can be find out & decompose the table without loss of data. 423. DBMS_SQL. DBMS_SQL. Dynamic Sql -Which uses late binding Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. BEGIN cur := DBMS_SQL. 426 Does Trigger Accepts arguments? A Trigger doesn't accept argument & have same name as table or procedure as it exist in separate namespace.then we have to go for BCNF.PARSE(cur. Denormalization- At the same time when information is required from more than one table at faster rate then it is wiser to add some sort of dependencies.CLOSE_CURSOR(cur).com . Every non key attribute is functionally dependant on just PK. 424. During normalization dependencies can be identified which can cause problems during deletion & updation . 4NF(BCNF)-The relation which has multiple candidate keys . 427. Dead.It is used in simplifying the structure of table.OPEN_CURSOR. Rolling Forward -To reapply to Data file to all changes that are recorded in Redo log file due to which data file contains committed & uncommitted data.EXECUTE(cur). END. Shared/exclusive LOCKS Shared/exclusive -When 2 transaction wants to read/write from db at the same time. 3NF-Transist dependencies.NATIVE).'CREATE TABLE X (Y DATE)'. DBMS_SQL. 1NF-Unnormalised data transfer to normalized form. 69 cur integer.

com . USER_TAB_COLUMNS gives you a list of tables as per Column.Encapsulation.Overloading.space allocated for schema object. Multithread Server-Handles request.SMON. Dedicated server .On a particular object.improve performance as I/O reduces.Important 430. Shared Pool . Object Previledge . information abt integrity constraints. Redo Log Buffer.PMON. For multiple user. Background process -DBWR. PL/SQL Signature Method.I/U/D/Exec System Previledge -Entire collection object -C/A/D SGA Comprises -Data Buffer. cleaning up cache. Clean Temporary Segment.Shared pool Buffer. PGA -A memory buffer that contains data and control information for a server process. LGWR. 3rd Max Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Queries-. SMON-Instance recovery at Start Up.writes all the changes been made to redo log buffer CKPT-Responsible to check DBWR and update control file to indicate most recent CKPT. For single user. PMON-Responsible for process recovery and user process fails. Buffer Cache-To improve data block recently used by user in order to improve the performance. It contains information such as parse tree and execution plan .Handles request.LGWR. 70 429. freeing a resource which was using process.Req to process unique SQL stmt submitted to DB. Data Dictionary -V$SESSION.To determine when remote dependant object get invalid.CKPT DBWR-Writes modified data blocks from DB buffer to data file. ORACLE INFO Packages.

5. -Join -No DML -No join-DML Index -are used for row selection in where and order by only if indexing on column DBMS_ALERT is a Transaction Processing Package while DBMS_PIPE is an Application Development package 435.com . First 5 Max No SQL> SELECT sal FROM(SELECT ABS(-sal) sal FROM emp GROUP BY -sal) WHERE ROWNUM<6.Varify the instance name 4. -To create the file that still store log entries.-- -Creating physical location for data in tables and indexes to be stored in DB.start instance 6.sal=2). Delete Duplicate rows Delete Emp where rowid not in(select max(rowid) from emp group by emp_no) 432. Three Steps in creating DB. 433. Users and role. Views-- -No Aggr function. 2.ora file 3. This is accomplished by create DB 1. operator. To manage Oracle DB services.Create and Backup the new DB. -To create logical structure of data dictionary.group by. Control file -250K Oracle Administration Assistant for W-NT is a DB management tool that enables to create DB administartor. views oracle process information. shut down. Back up existing DB. 71 select distinct sal from emp a where 3=(select count(distinct sal) from emp b where a.Create or Edit the init. Not clear 431.having -U/D without PK but not Insert. Database Configuration Assistant -To create DB Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Start Application management DB tool. Edit registry parameter setting. DB start up.

Hash Cluster-By placing data in close proximity k/s Hashing.com . DATABASE- Profile -To control system resources like memory. DB_BLOCK _SIZE RowID-BlockIDRowIdDatafileId Cluster Segment-To support use of cluster on the DB. CONTROL_FILE. Hybrid-both OLTP & DSS App. 440. Create or replace trigger ptpt before insert on batch for each row declare A varchar2 (20). Index column be in order by clause. Diff bet Trigger and Procedure- -Trigger need not required to be call (Implicitly fire on event) -No TCL used -Proc/fun can be used in trigger -No use of Long raw. 437. Data. End. Type of segment. If (a between '08' and ‘18’) then Raise_application_error (-20001.ora-is a parameter file like DB_NAME. TO check time nbetwen 8 am and 6 pm.LOB. DSS-Read only.'HH: MI: SSSS’) 1.Rollback.'Invalid Time'). End if.LONG -Procedure is prefered over trigger as proc stored in compile form as trigg p_code stores. RANDOM INFO Init. Temp. hight response time. 438. and CPU time. are running with this App. Index 439. Role -Collection of privileges. 72 436. begin Select substr (to_char (sysdate. Oracle environment- OLTP-Many users can read and update.2) into a from dual. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. disk space.

indexes. 73 441. Redo log file-Two or more redo log file make up a logical redo log. 442.Auditing- is used for noting down user's activity and statistics about the operations in data objects.link Refresh after seven days. nature of operation is stored in table AUD$ which is used by user sys.when call. Export-Putting data of tables in file. -Populate this area with application data. Data files-store actual data for tablespace. Then app. Active set. Formal parameter – Parameters define in definition. which is a logical unit of storage. SET TRANSACTION-We use set transaction statement to login a read only or read- write or to assign the current transaction to specified rollback segment. handles by OS. 443.com . The auditing are 1-Stmt 2-Previliges 3-Object 1-It is done to audit stmt activity . 444.The auditing information abt. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. memory area when execution is complete. -Free the. which is used to recover modifications that have not been written to data files in event of power outage. We can reduce network traffic- -By using snapshot -By storing related table in same tablespace -By avoiding Row chain. Actual parameter. Audit select on itemmaster. 2 redo log file. Control file-Used at start up to identify the DB and determine which redo log file and data file are created. 1 data file. Snapshot too old-We have to refresh the snapshot Alter snapshot as Select * from batch@dmaster. Every tablespace has one or more data file to store actual data for tables. which can be.A set of rows return by a mult-row query. Oracle DB uses three types of file structure. and clusters. -To record the usage of privilege -To record the activity on object. 446. Data is read and write to data file as needed. 1 control file. date & time of information. 445. -Process data in memory area. auditing is done and stored in table . Sql Statement Execution- -Reserves an area in memory called Private Sql Area.

-Attribute of partitioned table can't include long.sql 449. long raw or any lob data type. -----------------------------------). Utlbstat. Log_archieve_start =true -turn it on Log_archieve_dest=c:/oracle/ora81/archieve -location Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. -Per statement basis per session/stmt Audit any allows user to audit any schema object in the DB. -Bitmap indexes can't be defined on partitioned tables. We can use it to improve transaction throughout and certain type of queries for large tables.com . UTLESTAT spools the results of these SQL statements to a file called REPORT. 74 Nature of Auditing- Auditing is done on -Per session basis-one record is generated. B number C varchar2 (10)) partion by range(a.b) (partition pa1 values less than ('01-jan-99'. Edit the parameter initialization file. -A table can be partitioned based on ranges column values only.sql UTLESTAT creates table and views containing cumulative database performance summary information at the time when the script runs . 2) tablespace tsp1. We add partition using ALTER TABLE OR Create table aa ( a date. Accessing partition table- Select * from aa partion(pa1). 447.All the objects create by UTLBSTAT contain word login. The UTLBSTAT and UTLESTAT script to get general overview of database 's performance over a certain period of time.TXT Utlestat. Table partitioning- Table partitioning divides table data between two or more tablespaces and physical data file on separate disk.All the objects create by UTLESTAT contain word end. Restriction- -A table that is a part of cluster can't be partitioned. UTLBSTAT creates table and views containing cumulative database performance summary information at the time when the script runs . 448. Drop partion -Alter table AA drop partion pa1.

75

log_archieve_format="ARCH%S.LOG" - name format for archieve file .
%S for log sequence number .

By querying the V$SESSION view , we can determine who is logged on ,as well as
information such as the time of logon .

Kill a session - ALTER system kill session '&sid,&serial'
Select Sid,serial#,status from V$session where username='name';

450. Unbalanced Index –

if we do have lot of indexes on a table and we are doing I/U/D frequently then there
is a problem of disk contention . To check this problem sees the BLEVEL value in
DBA_INDEXES and if it is 1,2,3,4 then it’s ok else rebuild the index .

Alter index a_idx1 rebuild unrecoverable ;

451. Detect row chaining and row migration in tables

Row migration occurs when a database block doesn’t contain enough free space to
accommodate an update statement. In that case server moves the row to another
block and maintains a pointer to to new block in the row’s original block .when
pctfree is 0.
Row chaining in contrast , occurs when no single db block is larger enough to
accommodate a particular row . this is common when table contain several large
data types. It will reside in multiple database blocks .
An unpleasant side effect of both chaining and migration is that the oracle * server
must read more than one db block to read a single row . solution – move rows to a
temp table and then delete rows from original table and then insert it from temp table

452. What is the output of SIGN function?
1 for positive value,
0 for Zero,
-1 for Negative value.

453. You want to declare a record variable to have the same structure as
record in a given table. How do you accomplish this?

You can declare it using recordcursorname tablename%ROWTYPE; where recordcursorname
is the name of the cursor variable and tablename is the table in the database on which the
cursor's structure (columns and datatypes) will be modelled.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

76

454. What is the difference between Oracle's Rule Based and Cost Based optimizers?

Rule Based Optimizer (RBO) RBO follows a set of 15 hard-coded rules to generate
query execution plans. It does not take advantage of statistics. RBO is not supported
in Oracle 10g.

Cost Based Optimizer (CBO) CBO uses statistics on tables and indexes to generate
execution plans. CBO analyzes the following information to come up with a query
execution plan: Tables: number of rows, rows per block, etc. Indexes: uniqueness,
number of levels in B*tree structure, etc.

455. How do you raise an exception in PL/SQL?

Use RAISE errormessagename; to raise a previously defined exception (can be a
standard error or custom defined error) or simply Raise; if you want to re-raise an
exception in an exception block.

456. How do you get the error number and error message associated with a given
exception?

SQLCODE gives the error number and SQLERRM gives the error message. Both of these
are predefined Oracle functions.

457. you want to declare a variable in PL/SQL to be of the same type as a column in a
given table. How do you do this?

Use this syntax: variablename tablename.columnname%TYPE;
Example: employeeAgeType employees.emp_age%TYPE;

458. What are the components of physical database structure of Oracle database?

Oracle database is comprised of three types of files. One or more datafiles, two are

more redo log files, and one or more control files.

459. What are the components of logical database structure of Oracle database?

There are tablespaces and database's schema objects.

460. What is a tablespace?

A database is divided into Logical Storage Unit called tablespaces. A tablespace is

used to grouped related logical structures together.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

77

461. What is SYSTEM tablespace and when is it created?

Every Oracle database contains a tablespace named SYSTEM, which is automatically

created when the database is created. The SYSTEM tablespace always contains the

data dictionary tables for the entire database.

462. Explain the relationship among database, tablespace and data file.

Each databases logically divided into one or more tablespaces one or more data files

are explicitly created for each tablespace.

463. What is schema? A schema is collection of database objects of a user.

464. What are Schema Objects? Schema objects are the logical structures that

directly refer to the database's data. Schema objects include tables, views,

sequences, synonyms, indexes, clusters, database triggers, procedures, functions

packages and database links.

465. Can objects of the same schema reside in different tablespaces? Yes.

466. Can a tablespace hold objects from different schemes? Yes.

467. What is Oracle 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.

468. What is an Oracle view? A view is a virtual table. Every view has a query

attached to it. (The query is a SELECT statement that identifies the columns and rows

of the table(s) the view uses.)

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

The SELECT INTO Statement is most often used to create backup copies of tables or for archiving records. = Equal <> or != Not equal > Greater than < Less than >= Greater than or equal <= Less than or equal BETWEEN Between an inclusive range LIKE Search for a pattern 472. Double quotes may be acceptable in some databases.Instance startup STARTUP MOUNT . Give the stages of instance startup to a usable state where normal users may access it. 78 469. SELECT statements: SELECT column_name(s) FROM table_name SELECT DISTINCT column_name(s) FROM table_name SELECT column FROM table WHERE column operator value SELECT column FROM table WHERE column LIKE pattern SELECT column. The most important DDL statements in SQL are: CREATE TABLE .alters (changes) a database table DROP TABLE .deletes a database table CREATE INDEX . Operators used in SELECT statements. STARTUP NOMOUNT .com .The database is mounted STARTUP OPEN .deletes an index 471. The INSERT INTO Statements: Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.SUM(column) FROM table GROUP BY column HAVING SUM(column) condition value Note that single quotes around text values and numeric values should not be enclosed in quotes.SUM(column) FROM table GROUP BY column SELECT column. ??Kindly Confirm?? SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source WHERE column_name operator value 474.creates a new database table ALTER TABLE .creates an index (search key) DROP INDEX . 473.The database is opened 470.

. BETWEEN ... The Delete Statements: DELETE FROM table_name WHERE column_name = some_value Delete All Rows: DELETE FROM table_name or DELETE * FROM table_name 477.value2. .. value2... FROM table_name ORDER BY columnX...com .. a parent table can be dropped even when a child table exists. The Update Statement: UPDATE table_name SET column_name = new_value WHERE column_name = some_value 476... column2..) 479. 480. Variable names should start with an alphabet. Which system table contains information on constraints on all the tables created?obtained? USER_CONSTRAINTS. The IN operator may be used if you know the exact value you want to return for at least one of the columns.. value2.) 475. Which system tables contain information on privileges granted and privileges obtained? USER_TAB_PRIVS_MADE. Sort the Rows: SELECT column1... columnY.. column2. AND SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2 The values can be numbers... FROM table_name ORDER BY columnX DESC. Why does the following command give a compilation error? DROP TABLE &TABLE NAME. text. SELECT column_name FROM table_name WHERE column_name IN (value1. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. column2. SELECT column1.. 482. What is the use of CASCADE CONSTRAINTS? When this clause is used with the DROP command. 79 INSERT INTO table_name VALUES (value1. .) VALUES (value1. columnY ASC 478. 481. FROM table_name ORDER BY columnX DESC SELECT column1. Here the table name starts with an '&' symbol..) INSERT INTO table_name (column1. column2.. or dates. . . USER_TAB_PRIVS_RECD 483..

493. '1'. select.1. What is the use of the DROP option in the ALTER TABLE command? It is used to drop constraints specified on the table. 489. delete. and then executes it? RUN. 'NO' ).'1111111111').com . <>. alter. What operator performs pattern matching? LIKE operator. 496. State true or false. Which function is used to find the largest integer less than or equal to a specific value? FLOOR. 485. COMM = SAL*0. 488. What is the advantage of specifying WITH GRANT OPTION in the GRANT command? The privilege receiver can further grant the privileges he/she has obtained from the owner to any other user. What are the privileges that can be granted on a table by a user to others? Insert. 495. 486. 490. index. Which date function is used to find the difference between two dates? MONTHS_BETWEEN. What will be the output of the following query? SELECT DECODE(TRANSLATE('A'. 80 484. What is the value of comm and sal after executing the following query if the initial value of ‘sal’ is 10000 UPDATE EMP SET SAL = SAL + 1000. 491. ^= all denote the same operation? True. comm = 1000. execute. 492. State true or false.'1234567890'. EXISTS. What operator tests column for the absence of data? IS NULL operator.? sal = 11000. which command displays the SQL command in the SQL buffer. 497. update. references. ANY are operators in SQL? True.'YES'. 487. What command is used to get back the privileges offered by the GRANT command? REVOKE. Which command executes the contents of a specified file? START or @.? NO. SOME. all. 494. !=. Explanation : The query checks whether a given string is a numerical digit. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.

the WHERE clause of the SELECT command should contain a FALSE statement as in the following. Which is the subset of SQL commands used to manipulate Oracle Database structures. What command is used to create a table by copying the structure of another table? CREATE TABLE . AS SELECT command Explanation: To copy only the structure. CREATE TABLE NEWTABLE AS SELECT * FROM EXISTINGTABLE WHERE 1=2. What is the use of DESC in SQL? DESC has two purposes.Joining two tables by equating two common columns. What's an SQL injection? SQL Injection is when form data contains an SQL escape sequence and injects a new SQL query to be run. What is the sub-query? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. including tables? Data Definition Language (DDL). What is a join? Explain the different types of joins? Join is a query.Joining two tables in such a way that query can also retrieve rows that do not have corresponding join value in the other table.? _ for single character substitution and % for multi-character substitution. 81 498. Explanation : The query SELECT * FROM EMP ORDER BY ENAME DESC will display the output sorted on ENAME in descending order. 501.Joining two tables by equating two common columns.. What are the wildcards used for pattern matching. 504.Joining the table with itself. which retrieves related columns or rows from multiple tables. It is used to describe a schema as well as to retrieve rows from table in descending order. Self Join . 499. What is the parameter substitution symbol used with INSERT INTO command? & 503. 502.com . 505. Non-Equi Join . If the WHERE condition is true. Outer Join . 500. Equi Join . then all the rows or rows satisfying the condition will be copied to the new table.

506. DATE. VARCHAR2 does not pad blank spaces. It is not possible to use LONG column in WHERE or ORDER BY clause. 514. VARCHAR2. What is ON DELETE CASCADE? When ON DELETE CASCADE is specified Oracle maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or unique key value is removed. 509.com . What is referential integrity constraint? Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the referenced table. 507. How many LONG columns are allowed in a table? Is it possible to use LONG columns in WHERE clause or ORDER BY? Only one LONG column is allowed. Maximum of five save points are allowed. It enables rolling back part of a transaction. What is an integrity constraint? Integrity constraint is a rule that restricts values to a column in a table. 82 Sub-query is a query whose return values are used in filtering conditions of the main query. 512. What is the usage of SAVEPOINTS? SAVEPOINTS are used to subdivide a transaction into smaller parts. 511. NUMBER. 508. What is ROWID? ROWID is a pseudo column attached to each row of a table. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. LONG and LONG RAW. RAW. 513. rownumber are the components of ROWID. For CHAR the maximum length is 255 and 2000 is for VARCHAR2. It is 18 characters long. What are the data types allowed in a table? CHAR. 510. What is difference between CHAR and VARCHAR2? What is the maximum SIZE allowed for each type? CHAR pads blank spaces to the maximum length. blockno. What is the fastest way of accessing a row in a table? Using ROWID.

Can a view be updated/inserted/deleted? If Yes .To protect some of the columns of a table from other users.under what conditions? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. After an ascending sequence reaches its maximum value. 523. It is not possible. Because SYSDATE format contains time attached with it. NO CYCLE specifies that the sequence cannot generate more values after reaching its maximum or minimum value. it generates its maximum. will it validate the rows that are inserted with SYSDATE? It won't. 518. . After a descending sequence reaches its minimum. 83 515. 519. 516. 522. . What is a database link? Database link is a named path through which a remote database can be accessed. the table must be empty. 517.To hide complexity of a query. sequence name NEXTVAL.com . What are the pre-requisites to modify datatype of a column and to add a column with NOT NULL constraint? . . How to access the current value and next value from a sequence? Is it possible to access the current value in a session before accessing next value? Sequence name CURRVAL. it generates its minimum value. How will you activate/deactivate integrity constraints? The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE CONSTRAINT / DISABLE CONSTRAINT. What are the advantages of VIEW? . If unique key constraint on DATE column is created.To hide complexity of calculations. Where the integrity constraints are stored in data dictionary? The integrity constraints are stored in USER_CONSTRAINTS. 520. Only if you access next value in the session.To modify the datatype of a column the column must be empty. current value can be accessed. 521.To add a column with NOT NULL constrain.What is CYCLE/NO CYCLE in a Sequence? CYCLE specifies that the sequence continue to generate values after reaching either maximum or minimum value.

If a view on a single base table is manipulated will the changes be reflected on the base table? If changes are made to the tables and these tables are the base tables of a view. A developer would like to use referential datatype declaration on a variable. 528. %notfound 4. 4. Which of the following is not a feature of a cursor FOR loop? 1.lname%type. Use employee.lname%rowtype. 3. Fetches records from cursor. If left out. 2. %too_many_rows 3. Use employee. %found 2.com . and the corresponding table and column is EMPLOYEE. which of the following would cause an infinite loop to occur in a simple loop? 1. %rowtype 529. Declare it to be type LONG. Implicit cursors are no longer a feature in Oracle. 527. Opening and parsing of SQL statements. 524. END LOOP Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 525. Look up datatype for EMPLOYEE column on LASTNAME table and use that. 3. Implicit cursors are used for SQL statements that are not named. update and delete is not possible. respectively. LOOP 2. Which of the following statements is true about implicit cursors? 1. 3. Requires exit condition to be defined. Developers should use implicit cursors with great care. Which three of the following are implicit cursor attributes? 1. 84 A View can be updated/deleted/inserted if it has only one base table if the view is based on columns from one or more tables then insert. 4. 2. Implicit cursors are used in cursor for loops to handle data processing. The variable name is EMPLOYEE_LASTNAME. 2. 4. and LNAME. 526. then the changes will be reference on the view. Record type declaration. %rowcount 5. How would the developer define this variable using referential datatypes? 1.

select name. action 3. It causes the cursor to close 2. None. It causes the cursor to open 3. 10. WHERE movie_id = v_movie_id. END IF. It loads the current row values into variables 4. fetch 3. Read the following code: 1 CREATE OR REPLACE TRIGGER update_show_gross 2 {trigger information} 3 BEGIN Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com . OUT 3. cursor for loops handle cursor opening implicitly. Which line in the following statement will produce an error? 1. from action_table. 5. 562. rate. open 2. IF v_cost_per_ticket > 8. Which mode should be used for V_COST_PER_TICKET? 1. END. 11. v_cost_per_ticket {argument mode} NUMBER) 3. What happens when rows are found using a FETCH statement 1. SELECT cost_per_ticket 7. IN 2. It creates the variables to hold the current row values 563. 561. BEGIN 5. There are no errors in this statement. parse 4. 85 3. IS 4. IN OUT 564. (v_movie_id {Argument Mode} NUMBER. CREATE OR REPLACE PROCEDURE find_cpt 2. EXIT 560.5 THEN 6. into action_record 4. Read the following code: 1. RETURN 4. cursor action_cursor is 2. The command used to open a CURSOR FOR loop is 1. IF-THEN 4. INTO v_cost_per_ticket 8. FROM gross_receipt 9.

com .75) 2. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs? 1. RETURN v_yearly_budget. None 567. COST_PER_TICKET.75) 565.75) 3. Read the following code: CREATE OR REPLACE FUNCTION get_budget (v_studio_id IN NUMBER) RETURN NUMBER IS v_yearly_budget NUMBER. The trigger code should only execute when the column.cost_per_ticket > 3. All that applies 3. VARIABLE g_yearly_budget NUMBER EXECUTE g_yearly_budget := GET_BUDGET(11).cost_per_ticket > 3. Row only 4.cost_per_ticket > 3.75) 4. which trigger timing can you reference the NEW and OLD qualifiers? 1. is greater than $3. Which set of statements will successfully invoke this function within SQL*Plus? 1. WHERE (:new. WHEN (:new. Which trigger information will you add? 1. Only one 2. 86 4 {additional code} 5 END. 2.cost_per_ticket > 3. WHERE (new. WHEN (new. Oracle Forms trigger 568. All referenced 4. Statement only 3. BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Statement and Row 2. END. VARIABLE g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11).

UPDATE theater 5. Read the following code: CREATE OR REPLACE PROCEDURE calculate_budget IS v_budget studio. 3. 571. CREATE OR REPLACE PROCEDURE update_theater 2. VARIABLE g_yearly_budget NUMBER 569. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution. 7. 4. WHERE id = v_theater_id. SQLERRM Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 87 3.THEATER_NAME_UK) violated. (v_name IN VARCHAR v_theater_id IN NUMBER) IS 3. END IF. VARIABLE :g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11). When invoking this procedure.yearly_budget%TYPE. 2. BEGIN v_budget := get_budget(11). 4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement. RAISE_ERROR 2. 4. Which procedure can be used to create a customized error message? 1. END update_theater. 3. IF v_budget < 30000 THEN set_budget(11. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception.com . you encounter the error: ORA-000:Unique constraint(SCOTT. What effect will this have? 1. You are about to add an argument to CALCULATE_BUDGET. 2. Only the CALCULATE_BUDGET procedure needs to be recompiled. END. BEGIN 4. SET name = v_name 6. All three procedures are marked invalid and must be recompiled. How should you modify the function to handle this error? 1. 1. 570. Handle the error in EXCEPTION section by referencing the error code directly.30000000). The SET_BUDGET function will be marked invalid and must be recompiled before the next execution.

RAISE_APPLICATION_ERROR 4. Add RETURN right before the IS keyword. Examine this function: CREATE OR REPLACE FUNCTION set_budget (v_studio_id IN NUMBER. BEFORE DELETE ON gross_receipt 2. It should fire only once for the entire DELETE statement. RAISE_SERVER_ERROR 572. 88 3. END IF. 2. 573. v_new_budget IN NUMBER) IS BEGIN UPDATE studio SET yearly_budget = v_new_budget WHERE id = v_studio_id. IF SQL%FOUND THEN RETURN TRUE. The CHECK_THEATER trigger of the THEATER table has been disabled. END. END. BEFORE (gross_receipt DELETE) 4. Examine this database trigger CREATE OR REPLACE TRIGGER prevent_gross_modification {additional trigger information} BEGIN IF TO_CHAR(sysdate. AFTER DELETE ON gross_receipt 3. ENABLE TRIGGER check_theater. 3. Add RETURN number right before the IS keyword. END IF.com . ALTER TRIGGER check_theater ENABLE. This trigger must fire before each DELETE of the GROSS_RECEIPT table. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Which command can you issue to enable this trigger? 1. What additional information must you add? 1. DY) = MON THEN RAISE_APPLICATION_ERROR(-20000. COMMIT. 2. ENABLE check_theater. ELSE RETURN FALSE. ALTER TABLE check_theater ENABLE check_theater. Which code must be added to successfully compile this function? 1. FOR EACH ROW DELETED FROM gross_receipt 574. 4.Gross receipts cannot be deleted on Monday).

89

3. Add RETURN Boolean right after the IS keyword.
4. Add RETURN Boolean right before the IS keyword.

578. Under which circumstance must you recompile the package body after
recompiling the package specification?

1. Altering the argument list of one of the package constructs
2. Any change made to one of the package constructs
3. Any SQL statement change made to one of the package constructs
4. Removing a local variable from the DECLARE section of one of the
package constructs

579. Procedure and Functions are explicitly executed. This is different from a database
trigger. When is a database trigger executed?
1. When the transaction is committed
2. During the data manipulation statement
3. When an Oracle supplied package references the trigger
4. During a data manipulation statement and when the transaction is committed

580. Which Oracle supplied package can you use to output values and messages
from database triggers, stored procedures and functions within SQL*Plus?

1. DBMS_DISPLAY 2. DBMS_OUTPUT 3. DBMS_LIST 4. DBMS_DESCRIBE

581. What occurs if a procedure or function terminates with failure without being
handled?

1. Any DML statements issued by the construct are still pending and can be
committed or rolled back.
2. Any DML statements issued by the construct are committed
3. Unless a GOTO statement is used to continue processing within the BEGIN section,
the construct terminates.
4. The construct rolls back any DML statements issued and returns the unhandled
exception to the calling environment.

582. Examine this code

BEGIN
theater_pck.v_total_seats_sold_overall:= theater_pck.get_total_for_year;
END;
For this code to be successful, what must be true?

1. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR
function must exist only in the body of the THEATER_PCK package.
2. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the
THEATER_PCK package.
3. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the
specification of the THEATER_PCK package.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

90

4. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the
GET_TOTAL_FOR_YEAR function must exist in the specification of the
THEATER_PCK package.

583. A stored function must return a value based on conditions that are determined at
runtime. Therefore, the SELECT statement cannot be hard-coded and must be
created dynamically when the function is executed. Which Oracle supplied package
will enable this feature? ?????

1. DBMS_DDL
2. DBMS_DML
3. DBMS_SYN
4. DBMS_SQL

584 How to select last N records from a Table?

Select * from (select rownum a, CLASS_CODE,CLASS_DESC from clm) where a > ( select
(max(rownum)-10) from clm) Here N = 10

585. The following query has a Problem of performance in the execution of the
following

query where the table ter.ter_master have 22231 records. So the results are obtained
after hours.

Cursor rem_master(brepno VARCHAR2) IS
select a.* from ter.ter_master a
where NOT a.repno in (select repno from ermast) and
(brepno = 'ALL' or a.repno > brepno)
Order by a.repno

What are steps required tuning this query to improve its performance?

-Have an index on TER_MASTER.REPNO and one on ERMAST.REPNO
-Be sure to get familiar with EXPLAIN PLAN. This can help you determine the execution
path that Oracle takes. If you are using Cost Based Optimizer mode, then be sure that
your statistics on TER_MASTER are up-to-date. -Also, you can change your SQL to:

SELECT a.*
FROM ter.ter_master a
WHERE NOT EXISTS (SELECT b.repno FROM ermast b
WHERE a.repno=b.repno) AND
(a.brepno = 'ALL' or a.repno > a.brepno)
ORDER BY a.repno;

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

91

586. What is the difference between Truncate and Delete interms of Referential
Integrity?

DELETE removes one or more records in a table, checking referential Constraints (to
see if there are dependent child records) and firing any DELETE triggers. In the order
you are deleting (child first then parent) There will be no problems.

TRUNCATE removes ALL records in a table. It does not execute any triggers. Also, it
only checks for the existence (and status) of another foreign key Pointing to the
table. If one exists and is enabled, then you will get the following error. This
is true even if you do the child tables first.

ORA-02266: unique/primary keys in table referenced by enabled foreign keys
You should disable the foreign key constraints in the child tables before issuing
the TRUNCATE command, then re-enable them afterwards.

587. Describe the use of PL/SQL tables

PL/SQL tables are scalar arrays that can be referenced by a binary integer. They can
be used to hold values for use in later queries or calculations. In Oracle 8 they will be
able to be of the %ROWTYPE designation, or RECORD.

588. When is a declare statement needed?

The DECLARE statement is used in PL/SQL anonymous blocks such as with stand
alone, non-stored PL/SQL procedures. It must come first in a PL/SQL stand
alone file if it is used.

589. In what order should a open/fetch/loop set of commands in a PL/SQL block be
implemented if you use the NOTFOUND cursor variable in the exit when statement?
Why?

OPEN then FETCH then LOOP followed by the exit when. If not specified in this order
will result in the final return being done twice because of the way the %NOTFOUND is
handled by PL/SQL.

589. What are SQLCODE and SQLERRM and why are they important for PL/SQL
developers?

SQLCODE returns the value of the error number for the last error encountered. The
SQLERRM returns the actual error message for the last error encountered. They can be
used in exception handling to report, or, store in an error log table, the error that
occurred in the code. These are especially useful for the WHEN OTHERS exception.

590. How can you find within a PL/SQL block, if a cursor is open?

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

593. 591. AFTER. ROW. every row is determined by its primary key. What are snapshots? Snapshots are copies of remote data. What are cascading triggers? Executing one trigger may cause another trigger to also be executed. What happens if a tablespace clause is left off a primary key constraint? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. based upon queries. there are no duplicate rows. Another possible method is to just use the SHOW ERROR command. 594. How can you generate debugging output from PL/SQL? Use the DBMS_OUTPUT package. The DBMS_OUTPUT package can be used to show intermediate results from loops and the status of variables as the procedure is executed. 595. all tables have a primary key. In their simplest form. 596. every column is dependent on ONLY the primary key. INSERT. What are the types of triggers? There are 12 types of triggers in PL/SQL that consist of combinations of the BEFORE. but this only shows errors.com . The new package UTL_FILE can also be used. What Oracle package allows you to schedule one-off or recurring jobs in your database? DBMS_JOBS 597. 592. 92 Use the %ISOPEN cursor status variable. TABLE. What is 3rd normal form? All items are atomic. DELETE and ALL key words: BEFORE ALL ROW INSERT AFTER ALL ROW INSERT BEFORE INSERT AFTER INSERT etc. UPDATE. they can be thought of as a table created by a command such as: create table t as select * from z.

10-20 percent at database level. Where is most tuning done? 80-90 percent at application level. 600. DELETE or INSERT statement. For example. 93 This results in the index automatically generated being placed in the users' default tablespace. What's the difference between an Equijoins and a self-join? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. which is usually the same tablespace as where the table is being created which can cause performance problems. 598. What is a bind variable and why is it important? A bind variable is a placeholder in a query.com . 602. The way the Oracle shared pool (a very important shared memory data structure) operates is predicated on developers using bind variables. 599. Why should you care about the NLS_DATE_FORMAT? Because its' value (dd-mon-yy or dd-mon-rr) determines the results of your date arithmetic when you are dealing with years of 99 and 00. 601. How are reads and writes handled in Oracle that is different than almost every other database? Reads are not blocked by writes. What is the purpose of the SUBSTR string function? To return a specified substring from a string.nn. if your trigger contains a select statement or an update statement referencing the table it is triggering off of you will receive the error. 604.. 603. What is a mutating table? A mutating table is a table that is in the process of being modified by an UDPATE.

but if the && is used the user will not be bothered with a second prompt for the value. 609. Declare Begin Exception End Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 607.if. What is the TRANSLATE function? TRANSLATE is a simple function that does an orderly character-by-character substitution in a string. performance can be enhanced. In a Select statement. 605.234567890. I act like the Duracell bunny and just keep going and going. Their main advantage is that when relatively small tables must be constantly consulted. 610. 608. a self join does the same thing on a copy of the same table. Example: select TRANSLATE (7671234.com . Describe the PL/SQL Block structure. I follow this advice when at a client site. when I'm at home.then). What are PL/SQL Tables (or Arrays)? This is dependent upon your Oracle version. The result would be: GFG1BCD. PL/SQL Tables have only one dimension.'BCDEFGHIJ') from DUAL. 94 An Equijoins does an equality test between two fields in two different tables.3 that dimension could be a record. What's the most important 'Best Practice' guideline you follow? Ask for Help if you find yourself spending more than 30 minutes to solve a problem. 606. What's another Best Practice? Make code reviews a regular part of your development process. but after PL/SQL 2. I have found this useful during some data migrations where special characters needed to be translated. The format is TRANSLATE(string. what is the difference between a & and &&? Both pass in values at runtime. if they can be put in memory via a PL/SQL table.

619.00.com . What does the TO_NUMBER function do? It converts VARCHAR2 values to numbers. 618. 616.It resets the high water mark for a table if the REUSE STORAGE clause is not used. Why is the high water mark important? The high water mark is used in association with each individual table and tells Oracle 1. Where to start loading data during a SQL*Loader process 2.the var v_min_bal takes on the Type of sales.balance and the value of 10. What does truncating a table do? It deletes the data from the table. 620. How far to scan a table's information when doing a full-table scan. PL/SQL is compiled into PCode and the PCode is interpreted at runtime. What is an anonymous block? A PL/SQL Block without a name. 95 611. What is the default length of the CHAR column? 1 Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. End. Begin End.balance%TYPE := 10. 613. 612.00. . 617. Is PL/SQL truly compiled when stored in the database or is it interpreted? PL/SQL on the server is run in much the same fashion as Java is run anywhere. 614. What is %TYPE used for? v_min_bal sales. 615. Describe a nested PL/SQL Block. What is the purpose of the PL/SQL FETCH command? The FETCH command retrieves values returned by the cursor from the active set into the local variables. Declare Begin Begin End. not just a field. What is %ROWTYPE used for? Similar to %TYPE but for a record.

What is the purpose of the SQL*Plus command GET? Get the contents of a previously saved operating system file into the buffer. in a SELECT statement. use Telnet. FTO. and securing attributes to users. Strategy and analysis 2. What is the order of the stages of the system development cycle? 1. which character is used to pass in a value at runtime? The '&' character or the '&&' characters. 625. Design 3. What is the purpose of a referential integrity constraint? Enforce the rule that a child foreign key must have a valid parent primary key. 623. What are realms? Application security in Oracle Applications is maintained and managed by assigning responsibilities. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 96 621. excluding attributes. Build and document 4. etc. 626.com . A security realm is a list of objects (item source or a category) to which a user is granted access. 624. Transition 5. Production. 622. What is DNS? What does it stand for and why do we care that it exists? Dynamic Name Server is what allows us to type in names instead of IP addresses to get to Web servers. Internet Procurement 11i uses a security realm as an additional layer for application security.

Which variable type accepts any length of character up to 32767 bytes? VARCHAR2 634. 631. 628. With which symbol do you prefix a bind variable when you reference it in PL/SQL? : Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. all PL/SQL statements and the END clause 630. What keyword is used to assign a value to a variable that has a typical value? DEFAULT 636.com . What occurs during the production phase of the system development cycle? Perform normal routine maintenance. What data type is used to store large binary objects outside the database? The BFILE data type 632. How frequently are block declared variables initialized? Every time a block is executed 637. 97 627. what needs to be followed with a semicolon? All SQL statements. What operator is used to assign a value to a variable that doesn't have a typical value? := 635. What character do you type to execute an anonymous block? The / character. Which variable type accepts only character strings of a specified length? CHAR 633. A database trigger is fired automatically when what is executed? A DML statement 629. In a PL/SQL block.

What keyword is used when you populate a host variable from the SQL prompt? The VARIABLE keyword 640. 643. What is common among these cursor attributes. 639. 98 638. Give an example of the correct syntax to reference a row in a PL/SQL table. The data types of the variables specified in the INTO clause need to correspond with the values returned by the SELECT statement. How do you end each SQL statement in a PL/SQL block? With a . What are two statements that are true about the INTO clause? 1. SQL%NOTFOUND. Dept_table(15) 649. What does it mean when the cursor attribute SQL%FOUND returns the result TRUE? The most recent SQL statement issued affects one or more rows. You can't reference it outside the loop. You have to specify the same number of variables in the INTO clause as the values returned by the SELECT statement. 641. 2. SQL%FOUND. SQL%ISOPEN? They are all Boolean attributes. How do you begin defining a record type? TYPE emp_record_type IS RECORD.com . 2. Can you have more than one transaction in a PL/SQL block? Yes 642. 647. 646. What are two true statements concerning the index in a FOR loop? 1. You can use an expression to reference its existing value within the loop. Do PL/SQL records have a predefined data type? No. The primary key of a PL/SQL table must be of what data type? Scalar Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 645. 648.

%NOTFOUND 3 . Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. They are manipulated through specific statements in the block's executable actions. How long does the Oracle server wait if it cannot acquire the locks on the rows it needs in a SELECT FOR UPDATE? Indefinitely 657. 1. 653. 1. What are four attributes that provide status information about a cursor? 1. %ROWCOUNT 654. 1. 1. %ISOPEN 2. They process rows in an explicit cursor. 2. 656. You can use parameters to pass values to a cursor when it is open. %FOUND 4. and the cursor is closed when all the rows have been processed. %NOTFOUND 3. %FOUND 4. 3. They need to be declared and named before they can be used. Name two things true about cursor FOR loops. Name three things that are true about explicit cursors. 2. Name three things about using cursors with parameters. They automate processing as the cursor is automatically opened and the rows fetched for each iteration in the loop. 99 650.com . %ISOPEN 2. They individually process each row returned by a multi row SELECT statement. What clause do you use to apply updates and deletes to the row currently being addressed. %ROWCOUNT 655. Describe at least one way explicit cursor attributes are used. What is the term used for the rows produced by a query? Active set 651. 652. without having to explicitly reference the ROWID? You can use the explicit cursor attributes to test the success of each fetch before any further references are made to the cursor.

You can raise an exception explicitly by issuing the RAISE statement within the block. Parameters are used in a query when it executes. Once an Oracle error occurs. You need to reference your declared exception within the corresponding exception- handling routine. 1. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. When an exception occurs. Name three things about user-defined exceptions. 1. 658. 2. If you use the OTHERS clause. In the OPEN statement. 660. They are raised explicitly with RAISE statements. Selection of development tools 2. 3. What's another Best Practice? Set standards and guidelines for your application before anyone starts writing code. it should be placed last of all the exception-handling clauses. 2. PL/SQL processes only one handler before leaving the block. 3. you need to declare them in the DECLARE section of a PL/SQL block. 659. 662. Describe two aspects about exceptions. 100 2. Name three things true about trapping exceptions. How SQL is written in PL/SQL code. Exceptions cannot appear in assignment statements or SQL statements. 3. 2. 1. the associated exception is raised automatically.com . each formal parameter in the cursor declaration must have a corresponding real parameter. 1. When defining your own exceptions. What exception occurs when the conversion of a character string to a number fails? INVALID_NUMBER 661.

should present to the user a simple. describe conceptual vs logical vs physical designs. Explain the relationship between a Conceptual Data Model (CDM) and a Physical Data Model (PDM). which is independent of the targeted DBMS. using natural objects of information and natural associations between them.The process of constructing a model of information used in an enterprise based on a specific data model.g. the logical model contains entities. 664. and indexes. without having to consider the numerous parameters associated with the physical implementation such as data integrity constraints. Conceptual database design is the process of building a model of the essential part of the enterprise business process and the used information. data access speed and data storage efficiency. 101 3. which are represented in the physical model as tables. independent of all physical considerations. 4.com . Physical database design . Processes for code review and testing. and key groups. How the exception handling architecture is designed. Logical database design . A Conceptual Data Model lays the foundation for building shared databases and re-engineering the business. columns. The CDM allows the designer to concentrate solely on defining the objects in the information system and the relationships between them. A single CDM may therefore be associated with a number of PDMs targeting different DBMSs. Elaborating on 74. It Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. physical implementation-independent clear view of the format of the data sets and their descriptions. Most of the objects in the logical model correspond to a related object in the physical model. attributes. respectively. The model of information is independent of a particular implementation and other physical consideration. e. The CDM thus provides a clear and succinct picture of the information system.The process of producing a description of the implementation of the database on secondary storage. 663. The conceptual level schema.

666. What is the difference between call and execute sqlplus commands. 'MMDDYY'). sequence.? The CALL statement is SQL(and only understands SQL types).NextVal. 669. What data type column can not be used with INTERSECT? LONG 672.com . When is the MINUS keyword used? To remove those rows which are retrieved by one SELECT from those retrieved by another SELECT statement. number_string := TO_CHAR (10000).. but which is not an actual column of the table. What are the more common pseudo-columns? sequence. SysDate. VARCHAR might be a separate data type used for variable length character strings compared with different comparison semantics. If overloading was not supported in PL/SQL (TO_CHAR is a function in the STANDARD package). 670.CurrVal. 102 describes the storage structures and access methods used to achieve efficient access to the data. User 667. EXEC is really shorthand for begin/end. What is another name for ref cursors? cursor variables 671. 668. RowNum. then two different functions would be required to support conversions to character format. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. date_string := TO_CHAR (SYSDATE. Give an example of overloaded Built-in functions. What is the difference between VARCHAR and VARCHAR2? The VARCHAR data type is currently synonymous with the VARCHAR2 data type. RowID. It is recommended that you use VARCHAR2 rather than VARCHAR. What is a pseudo-column? A pseudo-column is a "column" that yields a value when selected. 665. UID. In a future version of Oracle.

SELECT c FROM t WHERE NOT c = 'x'. What is SQLERRM? A PL/SQL symbol that contains the error message associated with SQLCODE. b and c in a table of columns a.z. 675. 677. b. successful completion 681. When is the INTERSECT keyword used? To return only those rows that are the result of two or more SELECT statements. SELECT MGRNO FROM DEPT WHERE MGRNO IS NOT NULL MINUS SELECT EMPNO FROM EMP WHERE EDLEVEL >= 18. Write a query to find the duplicate record(s) of column a. When declaring an integer variable. for example in a loop or record counter.SELECT c FROM t WHERE c != 'x'. c FROM t GROUP BY a. 682. Any number of chararcters or numbers could be between the U and L. SQLCODE is equal to 0 and SQLERRM contains the string ORA-0000: normal. which are represented internally as 22-byte Oracle Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. ie the first character can be any character. SELECT c FROM t WHERE c LIKE '_EU%L'.com . 674. SELECT MGRNO FROM DEPT WHERE MGRNO IS NOT NULL INTERSECT SELECT EMPNO FROM EMP WHERE EDLEVEL < 18. Give an example of the NOT keyword. Give an example of the LIKE keyword. What are the benefits of using the PLS_INTEGER Data type in PL/SQL? If you have a whole-number counter. SQLCODE is equal to 0. 679. SELECT count(*). b. PLS_INTEGER is the most efficient numeric data type because its values require less storage than INTEGER or NUMBER values. List the numbers of all managers who do not hold advanced degrees.. What is ROWNUM? A pseudocolumn that indicates the order of the retrieved row. a. the next two must be EU and the last must be L. 678. c HAVING COUNT(*) > 1. What is SQLCODE? A predefined symbol that contains the Oracle error status of the previously executed PL/SQL statement. consider using a data type of PLS_INTEGER instead of INTEGER or NUMBER. The ROWNUM for the first returned row is 1. List the numbers of all managers who do not hold advanced degrees. Give an example of the MINUS keyword. 676. If a SQL statement executes without errors. 103 673. Give an example of the INTERSECT keyword. If a SQL statement executes successfully. 680. ROWNUM can limit the number of rows that are returned by a query.

What does pragma mean to Oracle? A pragma is simply a compiler directive. What is 4th normal form? Fourth normal form forbids independent one-to-many relationships between primary key columns and nonkey columns. 689. UNION will remove them.expr2. INTEGER. Also. the PMON process will clean up the lock on the data structure and release the latch. UNION will force a sort and cause performance degradation as compared to UNION ALL. UNION returns distinct rows selected by both queries while UNION ALL returns all the rows.expr3). The second parameter is optional and defaults to a single space. and that value must be atomic: there can be no repeating groups in a table that satisfies first normal form. NVL2(expr1.com . or NUMBER operations. which use library arithmetic. Describe RTRIM. Therefore. NVL2 . PLS_INTEGER operations use machine arithmetic. it must wait for the latch to be freed up by the process holding it. 686. The basic idea is to prevent concurrent access to shared data structures in the SGA.If expr1 is null then return expr2 else return expr1. What is 3rd normal form? (another explanation than #1) No nonkey column depends on another nonkey column. 684. This causes additional spinning ( looking for availability at fixed intervals of time ) of the process. The string passed as the first parameter is returned with all characters contained in the string passed as the second parameter removed from the right of the last character not found in the remove string. What is 1st normal form? Each cell must have one and only one value. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. so they are faster than BINARY_INTEGER. 701. What is 5th normal form? Fifth normal form breaks tables into the smallest possible pieces in order to eliminate all redundancy within a table. If a process is not able to obtain a latch.If expr1 is not null then the function will return expr2. A process acquires and holds the latch as long as the the data structure is in use. 702. Tables normalized to this extent consist of little more than the primary key. A dba has to monitor the latches for contention and make sure that CPU cycles are not being burnt on process spinning. What is 2nd normal form? Every nonkey column must depend on the entire primary key. If the table has no duplicates. a method to instruct the compiler to perform some compilation option. 700.' EDATPU') --> 'ORACL' 685. NVL(expr1. the function will return expr3. Otherwise. Describe UNION and UNION ALL. This process will spin until the latch is available. 687.'set']) RTRIM is the opposite of RPAD and similar to LTRIM. thereby causing extra load on the CPU. 683. rtrim('ORACLE UPDATE ') --> 'ORACLE UPDATE' rtrim('ORACLE UPDATE'. Explain the difference between NVL and NVL2. The function removes characters from the right-hand portion of a string. NVL . The expr1 can have any data type and arguments expr2 and expr3 can be of any data type other than LONG. In case the process dies without releasing the latch. 688. if the table has duplicates. RTRIM (string [.expr2). The data type of the return value is that of expr2.'EDATPU') --> 'ORACLE ' rtrim('ORACLE UPDATE'. What is a Latch? A Latch is a low level serialization mechanism that ( released as quickly as it is acquired ) protects shared data structures. 104 numbers.

we're able to count the employees by 1) department and job. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 709.sql script? autotrace 710. grouping(job) from emp group by rollup(deptno. as illustrated here: select deptno. 105 703. without having to use the EXPLAIN PLAN command. 705. What is an inline view? A sub query in the from clause of your main query. Give an example of an inline view and Top-N Query. This phrase describes a query that feeds one row of results to a parent query for the purpose of selection when the exact where clause criteria is not known? Single-row subquery. age ) IN ( SELECT country. What is an inline view? A sub query in a from clause used for defining an intermediate result set to query from. job. min(age) FROM athletes GROUP BY country). sal. SMITH CLERK 800 1 JAMES CLERK 950 2 ADAMS CLERK 1100 3 706. DEPTNO JOB COUNT(*) GROUPING(DEPTNO) GROUPING(JOB) 10 CLERK 1 0 0 10 MANAGER 1 0 0 10 PRESIDENT 1 0 0 10 3 0 1 20 ANALYST 2 0 0 20 CLERK 2 00 20 MANAGER 1 0 0 20 5 0 1 30 CLERK 1 0 0 30 MANAGER 1 0 0 30 SALESMAN 4 0 0 30 6 0 1 14 1 1 As shown in this example. Use of what command requires that you first run the plustrce. What SQL*Plus keyword is used for defining formats for how SQL*Plus displays column information? Set 708. 704. SELECT ename. country. What does AUTOTRACE do? Allows us to see the execution plan of the queries we've executed and the resources they used. What SQL*Plus command is useful for determining whether the "N rows selected" message will appear? Feedback 707. containing contestant name. job. age. 2) department. 713. To determine the youngest athlete representing each country. job. 712. The database for an international athletic competition consists of one table. 711.com . and represented country. how do you write the code? SELECT name. sal FROM emp ORDER BY sal) WHERE rownum <= 3. Does ROLLUP work with multiple columns? The ROLLUP feature can in fact be applied to multiple columns. job). age FROM athletes WHERE ( country. and 3) grand total. count(*). grouping(deptno). ATHLETES. What is a single-row sub query? The main query expects the subquery to return only one value. The result is multiple levels of rollup. rownum FROM (SELECT ename.

so that changes could be rolled back. In general it refers to getting the top-n rows from a result set. and less resource intensive than performing the same operation on a large object). 716. 721. 722. To ease administration burdens (derived from the fact that performing operations on small objects is inherently easier. and user-defined types and functions. the calling procedure must be the earlier of the two. performance stats and query plan used. Because a copy of the parameter set was made. including subselects. What are the two main index types that Oracle uses? B*Tree and Bitmap 718. Commercial Support is also available. faster.e. When are Bitmap indexes appropriate? In situations of low cardinality data. 715. To increase availability (derived from the fact that partitions are independent entities). data with few distinct values. It is the most advanced open-source database available anywhere. if that happens. 719. 2. PL/SQL Table or VARRAY types. i. supporting almost all SQL constructs. What is PostgreSQL? PostgreSQL is a sophisticated Object-Relational DBMS. What is a NOCOPY parameter? Where it is used? NOCOPY Parameter Option Prior to Oracle 8i there were three types of parameter-passing options to procedures and functions: IN: parameters are passed by reference OUT: parameters are implemented as copy-out IN OUT: parameters are implemented as copy-in/copy-out The technique of OUT and IN OUT parameters was designed to protect original values of them in case exceptions were raised. What are the three main reasons for partitioning a database? 1. Does the order of stored procedures in a package matter? It does if one procedure calls another. this method imposed significant CPU and memory overhead when the parameters were large data collections—for example. 722. 723. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What is a top-n query? select * from ( select ename from emp order by sal ) where rownum <= 3. What are the two types of cursors? Implicit (Oracle's) and explicit (yours). However.com . 720. rollback could be done. transactions. 106 714. 3. What does SQL_TRACE do? Enables logging of all application SQL. What does TKPROF do? Formats the raw trace files into a readable report. To enhance DML and query performance (potential to perform parallel DML).

. avg(). sal DESC Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. analytical fuction differ from aggregate function some of examples: SELECT ename "Ename". DENSE_RANK() OVER ( PARTITION BY deptno ORDER BY sal desc ) TopN FROM emp ) WHERE TopN <= 3 ORDER BY deptno. max(sal) .CREATE OR REPLACE PROCEDURE Update_Notes(Customer_Notes IN OUT NOCOPY Notebook) ISBEGIN . count(). Mention the differences between aggregate functions and analytical functions clearly with examples? Aggregate functions are sum(). security. 107 With the new NOCOPY option. in case of an exception rollback. deptno "Deptno". ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ENAME) "Seq" FROM emp ORDER BY deptno. count(*) . sal. min(sal) from emp. Memo VARCHAR2(2000)). ename SELECT * FROM ( SELECT deptno. 724.com . What are the advantages & disadvantages of packages ? Advantages: Modular approach. However. ROW_NUMBER() OVER ( PARTITION BY deptno ORDER BY sal DESC ) Top3 FROM emp ) WHERE Top3 <= 3 SELECT * FROM ( SELECT deptno. SUM(SAL) OVER (PARTITION BY deptno ORDER BY ename) "Dept Total". Created_By VARCHAR2(20). 725. sal. min() like: select sum(sal) .TYPE Notebook IS VARRAY(2000) OF Note. max(). performance improvement. avg(sal) . reusability Disadvantages: More memory may be required on the Oracle database server when using Oracle PL/SQL packages as the whole package is loaded into memory as soon as any object in the package is accessed. SUM(sal) OVER (ORDER BY deptno. Here is an example of using the NOCOPY parameter option: TYPE Note IS RECORD( Title VARCHAR2(15). Created_When DATE. which avoids copy overhead. ename. parameter set copy is not created and. OUT and IN OUT parameters are passed by reference. cannot be performed and the original values of parameters cannot be restored.END. ename. Encapsulation/hiding of business logic. sal "Sal".. ename) "Running Total".

insert * update...etc. It can be like before create... drop. before closing the instance) 727. With a schema.triggers. after starting the orcalce instance. With a database. How do we display the column values of a table using cursors without knowing the column names inside the loop? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. and users.triggers fire for each event for that specific user. what is the difference between database trigger and schema trigger? Database triggers are executed in response to particular events on tables in a databaseSchema triggers are fired when schema objects (tables) are modified. between database triggers on database or schema? Database triggers can be system triggers on a database or a schema. procedures.triggers fire for each event for all users. what is the difference between database server and data dictionary Database Server have many schemas.. 108 726. or lets say its an instance of the data with all schema info whereas the data dictionary contains raw data. delete. In database trigger: Trigger for a table /view is a database trigger like ( before . after startup.whereas datadictionary is the collection of information about all those objects like tables indexes views triggers etc in a database.views etc. after logon. insert * row level. later. of the entire data of the database alongwith compiled code of all packages. on error (any error occur in database.. May be the question is like this.. 728.infact the database server stores everything in raw format in the datadictionary they are not diff but areone and the same Database server is base on which everything resides. funtions and the all tables.com . it has only one instance for the organisation.drop 'Whats the diff. alter on schema ( these trigger are also called DDL trigger) Application trigger: before shutdown... statement level) 2 * 3 * 2 = 12 + instead off trigger for views schema triggers reffers to : before logoff.It Contains all the schemas. before create. Data Dictionary contains meta data information about each and every schemas object like tables procedures. Database server is a server on which the instance of oracle as server runs..

l_table_name VARCHAR2(2000) := 'FND_USER'. l_str VARCHAR2 (2000).. -.put_line.* FROM EMP A where rownum < 10.Open cursor. loop . Display the values from l_Record using dbms_output...IMP--This table name should be same as your from table in the above cursor l_value VARCHAR2 (2000).com .column_name Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. BEGIN FOR cr_rec IN cr_data LOOP -.You can use order by clause here if you want. CURSOR column_names (p_table_name VARCHAR2) IS SELECT * FROM all_tab_columns WHERE table_name = p_table_name.Close the loop and cursor DECLARE CURSOR cr_data IS SELECT ROWID. cursor cursorname is select * from emp.We should pass the same Table Name FOR cr_columc_rec IN column_names (l_table_name) LOOP l_str := 'Select ' || cr_columc_rec. fetch cursorname into l_Record. you can say .. A. 109 Declare a variable using PL/SQL %ROWTPE ( l_Record EMP%ROWTYPE)In the cursor. -.

110 || ' from '||l_table_name||' where rowid = '||chr(39) || cr_rec. dbms_flashback. 729. DBMS_OUTPUT. END. emp_cur emp%rowtype.? Flahsback is used to take your database at old state like a system restore in windows. at 10:40 am I want all my data from emp table then ? declare cursor c1 is select * from emp. END LOOP. EXECUTE IMMEDIATE l_str INTO l_value. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. END LOOP. DBMS_OUTPUT.What is Flashback query in Oracle9i.column_name || ' and Value is ' || l_value ).. No DDL and DML is allowed when database is in flashback condition.put_line ( 'Column is ' || cr_columc_rec.put_line ('Query is ' || l_str). begin dbms_flashback.com .enable_at_time(sysdate .15/1440)..ROWID||chr(39).disable. commit. open c1. User should have execute permission on dbms_flashback package for example: at 10:30 am from scott user : delete from emp.

emp_cur.com . before create.comm.empno. after startup. logon / logoff of the user. drop. so if the user tries to update a view. exit when c1%notfound. these tigger provide a means of tracking activity in the database Instead of trigger : A view cannot be updated . emp_cur. like alter. 111 loop fetch c1 into emp_cur. on error( any error occur in database. and server errors . delete.alter on schema ( these trigger are also called DDL trigger) Application trigger: before shutdown. Commit. Database trigger : this trigger will be fired when a database event ( dml operation ) occurs in the database table.hiredate.job. emp_cur. insert * update. then this trigger can be used . In database trigger: Trigger for a table /view is a database trigger like ( before . drop. like insert . insert into emp values(emp_cur. after logon. and schema trigger? INSTEAD OF Trigger control operation on view.deptno). update or delete. emp_cur. / select * from emp.. from which the view was created. emp_cur.emp_cur. where we can write the code so that the data will be updated in the table. and whenever an oracle error occurs.mgr. database trigger. before closing the instance) Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.. whenever a user logs on or log off. Database triggers fire whenever the database startup or is shutdown. end loop.sal.ename. the difference between instead of trigger. end. and also for the ddl events. truncate etc. 14 rows selected 730. statement level) 2 * 3 * 2 = 12 + instead off trigger for views schema triggers reffers to : before logoff. System triggers : this trigger will fire for database events like dtartup / shutdown of the server. insert * row level. after starting the orcalce instance. They can be used to make non-updateable views updateable and to override the behavior of view that are updateable. emp_cur. not table.

What are the components of Physical database structure of Oracle Database? ORACLE database is comprised of three types of files. Can a View based on another View ? Yes. --Store complex queries. sequences. 736. What is schema? A schema is collection of database objects of a User. 733. 732. by restricting access to a predetermined Set of rows and columns of a table. which is automatically created when the database is created. Table data is stored in rows and columns. (The Query is a SELECT statement that identifies the columns and rows of the table(s) the view uses. What is SYSTEM tablespace and when is it Created? Every ORACLE database contains a tablespace named SYSTEM. One or more Data files. What are the components of Logical database structure of ORACLE database? Tablespaces and the Database's Schema Objects. Can objects of the same Schema reside in different tablespaces. 734. What are Schema Objects ? Schema objects are the logical structures that directly refer to the database's data. views.? Yes. The SYSTEM tablespace always contains the data dictionary tables for the entire database. two are more Redo Log files. The tables of a database hold all of the user accessible data. clusters. What is a Sequence ? A sequence generates a serial list of unique numbers for numerical columns of a database's tables.) 742. What is Table ? A table is the basic unit of data storage in an ORACLE database. 740. Explain the relationship among Database. 739. 743. 738. Schema objects include tables. 741. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 745. --Present the data in a different perspective from that of the base table. Each databases logically divided into one or more tablespaces One or more data files are explicitly created for each tablespace. 744. Tablespace and Data file. procedures. Do views contain Data ? Views do not contain or store data. database triggers.com . --Simplify commands for the user. 112 731. What are the advantages of Views ? --Provide an additional level of table security. and one or more Control files. indexes. What is a Tablespace? A database is divided into Logical Storage Unit called tablespaces. What is a View ? A view is a virtual table. A tablespace is used to grouped related logical structures together. functions packages and database links. --Hide data complexity. Every view has a Query attached to it. Can a Tablespace hold objects from different Schemes ? Yes. 737. synonyms. 735.

A private database link can be used only when the owner of the link specifies a global object name in a SQL statement or in the definition of the owner's views or procedures. 754. 757. 761. What are Clusters ? Clusters are groups of one or more tables physically stores together to share common columns and are often used together. 756. 113 746. views or program units of a remote database. 749. What is Public Database Link ? Public database link is created for the special user group PUBLIC. What is cluster Key ? The related columns of the tables in a cluster are called the Cluster Key. A public database link can be used when any user in the associated database specifies a global object name in a SQL statement or object definition. 747. Changes to table data are automatically incorporated into all relevant indexes. 748. 751. What is Hash Cluster ? A row is stored in a hash cluster based on the result of applying a hash function to the row's cluster key value. How is Indexes Update ? Indexes are automatically maintained and used by ORACLE. sequence or program unit. The resulting hash key value points directly to the area on disk that stores the specified rows. --Simplify the SQL statements for database users. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Public Database Link & Network Database Link. 755. 760. What is a Public Synonyms ? A Public synonym can be accessed by any user on the database. Index can be created on one or more columns of a table. All rows with the same hash key value are stores together on disk.com . When can Hash Cluster used ? Hash clusters are better choice when a table is often queried with equality queries. What is an Index ? An Index is an optional structure associated with a table to have direct access to rows. 750. What is a Private Synonyms ? A Private Synonyms can be accessed only by the owner. What are synonyms used for ? --Synonyms are used to : Mask the real name and owner of an object. What are the types of Database Links ? Private Database Link. What are the types of Synonyms? There are two types of Synonyms Private and Public. What is Database Link ? A database link is a named object that describes a "path" from one database to another. 753. What is a Synonym ? A synonym is an alias for a table. view. What is Private Database Link ? Private database link is created on behalf of a specific user. What is Index Cluster ? A Cluster with an index on the Cluster Key. which can be created to increase the performance of data retrieval. 752. ---Provide public access to an object --Provide location transparency for tables. 759. For such queries the specified cluster key value is hashed. 758.

A database's data files contain all the database data. Block size is specified in INIT. obtained in a single allocation. What is a Data File ? Every ORACLE database has one or more physical data files. What is an Index Segment ? Each Index has an Index segment that stores all of its data. 772. The data of logical database structures such as tables and indexes is physically stored in the data files allocated for a database. 767. What is Network Database link ? Network database link is created and managed by a network domain service. How to define Data Block size ? A data block size is specified for each ORACLE database when the database is created. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 764. What are the uses of Rollback Segment ? Rollback Segments are used to generate read- consistent database information during database recovery to rollback uncommitted transactions for users. A network database link can be used when any user of any database in the network specifies a global object name in a SQL statement or object definition. Each cluster has a data segment. 768.com . What is Rollback Segment ? A Database contains one or more Rollback Segments to temporarily store "undo" information. What is a Segment ? A segment is a set of extents allocated for a certain logical structure. The data of every table in the cluster is stored in the cluster's data segment. When the statement finishes execution. 775. 769. When this occurs . 773. 766.ORA file and can’t be changed latter. What is a Temporary Segment ? Temporary segments are created by ORACLE when a SQL statement needs a temporary work area to complete execution. One data block corresponds to a specific number of bytes of physical database space on disk. Once created a data file can't change size. 771. Index Segment. 114 762. the temporary segment extents are released to the system for future use. 770. A database users and allocated free database space in ORACLE data blocks. All of the table's data is stored in the extents of its data segment. What are the Characteristics of Data Files ? A data file can be associated with only one database. the data for the row is stored in a chain of data block (one or more) reserved for that segment. What is Row Chaining ? In Circumstances. 774. What are the different types of Segments ? Data Segment. What is a Data Segment ? Each Non-clustered table has a data segment. What is an Extent ? An Extent is a specific number of contiguous data blocks. 763. all of the data for a row in a table may not be able to fit in the same data block. used to store a specific type of information. 765. One or more data files form a logical unit of database storage called a tablespace. Rollback Segment and Temporary Segment. What is Data Block ? ORACLE database's data is stored in data blocks.

Can an Integrity Constraint be enforced on a table if some existing table data does not satisfy the constraint ? No. 779. --Time stamp of database creation. 780. What is a Data Dictionary ? The data dictionary of an ORACLE database is a set of tables and views that are used as a read-only reference about the database.com . Describe the different type of Integrity Constraints supported by ORACLE ? NOT NULL Constraint . 787. 781. What is the use of Control File ? When an instance of an ORACLE database is started. 777. 785. Describe Referential Integrity ? A rule defined on a column (or set of columns) in one table that allows the insert or update of a row only if the value for the column or set of columns (the dependent value) matches a value in a column of a related table (the referenced value). CHECK Constraint . --Database Name. It contains the following information. 778. integrity constraints defined for tables in the database and space allocated for a schema object and how much of it is being used. What is a Redo Log ? The set of Redo Log files for a database is collectively known as the database's redo log. its control file is used to identify the database and redo log files that must be opened for database operation to proceed. 783. What are the Referential actions supported by FOREIGN KEY integrity constraint ? UPDATE and DELETE Restrict . What is difference between UNIQUE constraint and PRIMARY KEY constraint ? A column defined as UNIQUE can contain NULLs while a column defined as PRIMARY KEY can't contain Nulls.Disallows duplicate values and NULLs in a column or set of columns. PRIMARY KEY Constraint . 786. the valid users of an ORACLE database. 115 776.A referential integrity rule that disallows the update or deletion of referenced data. What does a Control file Contain ? A Control file records the physical structure of the database. It stores information about both the logical and physical structure of the database. What is an Integrity Constrains ? An integrity constraint is a declarative way to define a business rule for a column of a table. UNIQUE Constraint . It also specifies the type of data manipulation allowed on referenced data and the action to be performed on dependent data as a result of any action on referenced data. What is the use of Redo Log Information ? The Information in a redo log file is used only to recover the database from a system or media failure prevents database data from being written to a database's data files. What is the function of Redo Log ? The Primary function of the redo log is to record all changes made to data. --Names and locations of a database's files and redo log files. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. FOREIGN KEY Constrain . 782.Require each value in a column or set of columns match a value in a related table's UNIQUE or PRIMARY KEY.Disallows NULLs in a table's column. It is also used in database recovery.Disallows values that do not satisfy the logical expression of the constraint. 784.Disallows duplicate values in a column or set of columns.

com . What are the components of SGA ? Database buffers. 116 DELETE Cascade . the SYSDATE. What do Database Buffers contain ? Database buffers store the most recently used blocks of database data. 795. What is the maximum number of CHECK constraints that can be defined on a column ? No Limit. 799. 791. What do Redo Log Buffers contain ? Redo Log Buffer stores redo entries a log of changes made to the database. It can also contain modified data that has not yet been permanently written to disk. 797. 788. 794. (or) Combination of memory structure and background process. Redo Log Buffer the Shared Pool and Cursors. It is a shadow process created automatically to facilitate communication between the user and the server process. What is Shared SQL Area ? A Shared SQL area is required to process every unique SQL statement submitted to a database and contains information such as the parse tree and execution plan for the corresponding statement. What is SGA ? The System Global Area (SGA) is a shared memory region allocated by ORACLE that contains data and control information for one ORACLE instance. 792. sequence.When a referenced row is deleted all associated dependent rows are deleted. 798. What is self-referential integrity constraint ? If a foreign key reference a parent key of the same table is called self-referential integrity constraint.USER or USERENV SQL functions.UID. What is User Process ? A user process is created and maintained to execute the software code of an application program. 789. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 800. What constitute an ORACLE Instance ? SGA and ORACLE background processes constitute an ORACLE instance. What is PGA ? Program Global Area (PGA) is a memory buffer that contains data and control information for a server process. or the pseudo columns LEVEL or ROWNUM. What is Shared Pool ? Shared Pool is a portion of the SGA that contains shared memory constructs such as shared SQL areas. 790. 796. What is Cursor ? A Cursor is a handle ( a name or pointer) for the memory associated with a specific statement. What are the Limitations of a CHECK Constraint ? The condition must be a Boolean expression evaluated using the values in the row being inserted or updated And can't contain sub queries. 793.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What is Server Process ? Server Process handles requests from connected user process.Recover Dnnn .Server. DBWR also writes when Checkpoint occurs.Database Writer. When does LGWR write to the database ? LGWR writes redo log entries into an on-line redo log file when transactions commit and the log buffer files are full. 117 Second Set 1.Dispatcher LCKn .Process Monitor ARCH . 9. What is a Multi-threaded Server Configuration ? In a Multi-threaded Server Configuration many user processes share a group of server process. LGWR . What are the two types of Server Configurations ? Dedicated Server Configuration and Multi-threaded Server Configuration. 3. 5.Check Point SMON . 8. What Does DBWR do ? Database writer writes modified blocks from the database buffer cache to the data files. 10.com . 2. When Does DBWR write to the database ? DBWR writes when more data needs to be read into the SGA and too few database buffers are free. The least recently used data is written to the data files first.Lock Snnn . What is a Parallel Server option in ORACLE ? A configuration for loosely coupled systems where multiple instances share a single physical database is called Parallel Server. What does LGWR do ? Log Writer (LGWR) writes redo log entries generated in the redo log buffer of the SGA to on-line Redo Log File. What is Dedicated Server Configuration ? In a Dedicated Server Configuration a Server Process handles requests for a Single User Process.System Monitor PMON . 7. 4.Log Writer CKPT .Archiver RECO . A server process is in charge of communicating with the user process and interacting with ORACLE carry out requests of the associated user process. Name the ORACLE Background Process ? DBWR . 6.

What is the function of Lock (LCKn) Process ? Lock (LCKn) is used for inter-instance locking when the ORACLE Parallel Server option is used. 17. ARCH is active only when a database's redo log is used in ARCHIVELOG mode. the local RECO attempts to connect to remote databases and automatically complete the commit or rollback of the local portion of any pending distributed transactions. The changes made by the SQL statements of a transaction become visible to other user sessions transactions that start only after transaction is committed. How many Dispatcher Processes are created ? At least one Dispatcher process is created for every communication protocol in use. 18. When does a Transaction end ? When it is committed or Rollbacked. What is function of RECO ? Recover (RECO) is used to resolve distributed transactions that are pending due to a network or system failure in a distributed database..com . At timed intervals. These transactions are eventually recovered by SMON when the tablespace or file is brought back on-line SMON also coalesces free extents within the database to make free space contiguous and easier to allocate. What is the maximum number of Lock Processes used ? Though a single LCK process is sufficient for most Parallel Server systems upto Ten Locks (LCK0. 23... What are the functions of SMON ? System Monitor (SMON) performs instance recovery at instance start-up. 19. 20. 14. 16. Define Transaction ? A Transaction is a logical unit of work that comprises one or more SQL statements executed by a single user. What are functions of PMON ? Process Monitor (PMON) performs process recovery when a user process fails PMON is responsible for cleaning up the cache and Freeing resources that the process was using PMON also checks on dispatcher and server processes and restarts them if they have failed. What is the function of checkpoint(CKPT)? The Checkpoint (CKPT) process is responsible for signaling DBWR at checkpoints and updating all the data files and control files of the database. What is the function of ARCH ? Archiver (ARCH) copies the on-line redo log files to archival storage when they are full. 15. 12. In a multiple instance system (one that uses the Parallel Server). What does COMMIT do ? COMMIT makes permanent the changes resulting from all SQL statements in the transaction.. What does ROLLBACK do ? ROLLBACK retracts any of the changes resulting from the SQL statements in the transaction. 13. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. SMON of one instance can also perform instance recovery for other instance that have failed SMON also cleans up temporary segments that are no longer in use and recovers dead transactions skipped during crash and instance recovery because of file-read or off-line errors. What is the function of Dispatcher (Dnnn)? Dispatcher (Dnnn) process is responsible for routing requests from connected user processes to available shared server processes and returning the responses back to the appropriate user processes. 22. 21. 118 11.LCK9) are used for inter-instance locking.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 29. What are the different approaches used by Optimizer in choosing an execution plan ? Rule-based and Cost-based. What is the effect of setting the value "ALL_ROWS" for OPTIMIZER_GOAL parameter of the ALTER SESSION command ? This value causes the optimizer to the cost-based approach for all SQL statements in the session regardless of the presence of statistics and to optimize with a goal of best throughput. Otherwise the OPTIMIZER chooses RULE based approach. What is the effect of setting the value "choose" for optimizer_goal. 30. 32. What is the effect of setting the value 'FIRST_ROWS' for OPTIMIZER_GOAL parameter of the ALTER SESSION command ? This value causes the optimizer to use the cost-based approach for all SQL statements in the session regardless of the presence of statistics and to optimize with a goal of best response time. What are the values that can be specified for OPTIMIZER MODE Parameter ? COST and RULE. What is Read-Only Transaction ? A Read-Only transaction ensures that the results of each query executed in the transaction are consistent with respect to the same point in time. What is the function of Optimizer ? The goal of the optimizer is to choose the most efficient way to execute a SQL statement. 36. 25. What is SAVE POINT ? For long transactions that contain many SQL statements. 33. 26. This allows the option of later rolling back all work performed from the current point in the transaction to a declared save point within the transaction. 35. Otherwise OPTIMIZER chooses RULE-based approach. intermediate markers or save points can be declared which can be used to divide a transaction into smaller parts. 34. 28.com . What is the effect of setting the value of OPTIMIZER_MODE to 'RULE' ? This value causes the optimizer to choose the rule_based approach for all SQL statements issued to the instance regardless of the presence of statistics. 31. 119 24. What are the values that can be specified for OPTIMIZER_GOAL parameter of the ALTER SESSION Command ? CHOOSE. parameter of the ALTER SESSION Command ? The Optimizer chooses Cost_based approach and optimizes with the goal of best throughput if statistics for at least one of the tables accessed by the SQL statement exist in the data dictionary. ALL_ROWS. What are the factors that affect OPTIMIZER in choosing an Optimization approach ? The optimizer_mode initialization parameter statistics in the Data Dictionary the optimizer_goal parameter of the ALTER SESSION command hints in the statement. 27. FIRST_ROWS and RULE. What is Execution Plan ? The combination of the steps the optimizer chooses to execute a statement is called an execution plan. Will the Optimizer always use COST-based approach if OPTIMIZER_MODE is set to "Cost'? Presence of statistics in the data dictionary for at least one of the tables accessed by the SQL statements is necessary for the OPTIMIZER to use COST-based approach.

A trigger does not apply to data loaded before the definition of the trigger. What is COST-based approach to optimization ? Considering available access paths and determining the most efficient execution plan based on statistics in the data dictionary for the tables accessed by the statement and their associated clusters and indexes. 120 37. update to. audit data modifications. What is a Procedure ? A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a specific problem or perform a set of related tasks. 43. What are the uses of Database Trigger ? Database triggers can be used to automatic data generation.com . 41. 46. What is RULE-based approach to optimization ? Choosing an executing plan based on the access paths available and the ranks of these access paths. What is Database Trigger ? A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in. 38. 47. What are Roles ? Roles are named groups of related privileges that are granted to users or other roles. Packages and Database Triggers. What is a Package ? A Package is a collection of related procedures. enforce complex Integrity constraints. What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ? Procedures and Functions. it does not guarantee all data in a table conforms to the rules established by an associated trigger. and loaded into memory once) 45. 42. A constraint applies to existing data in the table and any statement that manipulates the table. What is the effect of setting the 'RULE' for OPTIMIER_GOAL parameter of the ALTER SESSION Command ? This value causes the optimizer to choose the rule-based approach for all SQL statements in a session regardless of the presence of statistics. therefore. What is difference between Procedures and Functions ? A Function returns a value to the caller where as a Procedure does not. 39. 40. What are the differences between Database Trigger and Integrity constraints ? A declarative integrity constraint is a statement about the database that is always true. or delete from a table. 44. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What are the advantages of having a Package ? Increased functionality (for example. A trigger can be used to enforce transitional constraints where as a declarative integrity constraint cannot be used. functions. and customize complex security authorizations. variables and other package constructs together as a unit in the database. global package variables can be declared and used by any procedure in the package) and performance (for example all objects of the package are parsed compiled. 48.

121

49. What are the uses of Roles ?

Reduced Granting of Privileges - Rather than explicitly granting the same set of privileges to
many users a database administrator can grant the privileges for a group of related users
granted to a role and then grant only the role to each member of the group.

DYNAMIC PRIVILEGE MANAGEMENT - When the privileges of a group must change, only the
privileges of the role need to be modified. The security domains of all users granted the
group's role automatically reflect the changes made to the role.

SELECTIVE AVAILABILITY OF PRIVILEGES - The roles granted to a user can be selectively enable
(available for use) or disabled (not available for use). This allows specific control of a
user's privileges in any given situation.

APPLICATION AWARENESS - A database application can be designed to automatically enable
and disable selective roles when a user attempts to use the application.

50. How to prevent unauthorized use of privileges granted to a Role ? By creating a Role with a
password.

51. What is default tablespace ? The Tablespace to contain schema objects created
without specifying a tablespace name.

52. What is Tablespace Quota ? The collective amount of disk space available to the objects
in a schema on a particular tablespace.

53. What is a profile ? Each database user is assigned a Profile that specifies limitations on
various system resources available to the user.

54. What are the system resources that can be controlled through Profile ?

The number of concurrent sessions the user can establish the CPU processing time available to
the user's session the CPU processing time available to a single call to ORACLE made by a
SQL statement the amount of logical I/O available to the user's session the amout of logical
I/O available to a single call to ORACLE made by a SQL statement the allowed amount of
idle time for the user's session the allowed amount of connect time for the user's session.

55. What is Auditing ? Monitoring of user access to aid in the investigation of database use.

56. What are the different Levels of Auditing ? Statement Auditing, Privilege Auditing and
Object Auditing.

57. What is Statement Auditing ? Statement auditing is the auditing of the powerful system
privileges without regard to specifically named objects.

58. What is Privilege Auditing ? Privilege auditing is the auditing of the use of powerful system
privileges without regard to specifically named objects.

59. What is Object Auditing ? Object auditing is the auditing of accesses to specific
schema objects without regard to user.

60. What is Distributed database ?

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

122

A distributed database is a network of databases managed by multiple database servers
that appears to a user as single logical database. The data of all databases in the
distributed database can be simultaneously accessed and modified.

61. What is Two-Phase Commit ? Two-phase commit is mechanism that guarantees a
distributed transaction either commits on all involved nodes or rolls back on all involved nodes
to maintain data consistency across the global distributed database. It has two phases, a
Prepare Phase and a Commit Phase.

62. Describe two phases of Two-phase commit ?

Prepare phase - The global coordinator (initiating node) ask a participants to prepare (to
promise to commit or rollback the transaction, even if there is a failure)

Commit-Phase - If all participants respond to the coordinator that they are prepared, the
coordinator asks all nodes to commit the transaction, if all participants cannot prepare, the
coordinator asks all nodes to roll back the transaction.

63. What is the mechanism provided by ORACLE for table replication ?
Snapshots and SNAPSHOT LOGs

64. What is a SNAPSHOT ?
Snapshots are read-only copies of a master table located on a remote node which is
periodically refreshed to reflect changes made to the master table.

65. What is a SNAPSHOT LOG ?
A snapshot log is a table in the master database that is associated with the master table.
ORACLE uses a snapshot log to track the rows that have been updated in the master table.
Snapshot logs are used in updating the snapshots based on the master table.

66. What is a SQL* NET? SQL *NET is Oracle’s mechanism for interfacing with the
communication protocols used by the networks that facilitate distributed processing and
distributed databases. It is used in client-server and server-server communications.

67. What are the steps involved in Database Startup ? Start an instance, Mount the Database
and Open the Database.

68. What are the steps involved in Database Shutdown ? Close the Database, Dismount the
Database and Shutdown the Instance.

69. What is Restricted Mode of Instance Startup ?
An instance can be started in (or later altered to be in) restricted mode so that when the
database is open connections are limited only to those whose user accounts have been
granted the Restricted Session system privilege.

70. What are the different modes of mounting a Database with the Parallel Server ?

1)Exclusive Mode If the first instance that mounts a database does so in exclusive
mode, only that Instance can mount the database.

2) Parallel Mode If the first instance that mounts a database is started in parallel
mode, other instances that are started in parallel mode can also mount the database.

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

123

71. What is Full Backup? A full backup is an operating system backup of all data files, on-line
redo log files and control file that constitute ORACLE database and the parameter.

72. Can Full Backup be performed when the database is open? No.

73. What is Partial Backup? A Partial Backup is any operating system backup short of a full
backup, taken while the database is open or shut down.

74.WhatisOn-lineRedoLog?
The On-line Redo Log is a set of two or more on-line redo files that record all committed
changes made to the database. Whenever a transaction is committed, the corresponding
redo entries temporarily stores in redo log buffers of the SGA are written to an on-line redo log
file by the background process LGWR. The on-line redo log files are used in cyclical fashion.

75. What is Mirrored on-line Redo Log? A mirrored on-line redo log consists of copies of on-line
redo log files physically located on separate disks, changes made to one member of the
group are made to all members.

76. What is Archived Redo Log? Archived Redo Log consists of Redo Log files that have
archived before being reused.

77. What are the advantages of operating a database in ARCHIVELOG mode over operating
it in NO ARCHIVELOG mode ? Complete database recovery from disk failure is possible only in
ARCHIVELOG mode. Online database backup is possible only in ARCHIVELOG mode.

78. What is Log Switch ? The point at which ORACLE ends writing to one online redo log file
and begins writing to another is called a log switch.

79. What are the steps involved in Instance Recovery ?

1. Rolling forward to recover data that has not been recorded in data files, yet has been
recorded in the on-line redo log, including the contents of rollback segments.
2. Rolling back transactions that have been explicitly rolled back or have not been committed
as indicated by the rollback segments regenerated in step a.
Releasing any resources (locks) held by transactions in process at the time of the failure.
3. Resolving any pending distributed transactions undergoing a two-phase commit at the
time of the instance failure.

80. What is a Database instance ? Explain? A database instance (Server) is a set of memory
structure and background processes that access a set of database files.
The process can be shared by all users.
The memory structure that are used to store most queried data from database. This
helps up to improve database performance by decreasing the amount of I/O performed
against data file.

81. What is Parallel Server ? Multiple instances accessing the same database (Only In Multi-
CPU environments)

82. What is a Schema ? The set of objects owned by user account is called the schema.

83. What is an Index ? How it is implemented in Oracle Database ?

Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.com

85. What are the basic elements of Base configuration of an oracle Database ? It consists of --One or more data files. Redo log buffers. 86. Dictionary Cache Buffers. In a database environment this will often happen because of not issuing proper row lock commands. What is SGA ? The System Global Area in a Oracle database is the area in memory to facilitates the transfer of information between users. 90. What is a Shared SQL pool ? The data dictionary cache is stored in an area in SGA called the Shared SQL Pool. --Two or more redo log files.com . What are clusters ? Group of tables physically stored together because they share common columns and are often used together is called Cluster. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. An index is automatically created when a unique of primary key constraint clause is specified in create table comman (Ver 7. 88. 124 An index is a database structure used by the server to have direct access of a row in a table. These locks will be released automatically when a commit/rollback operation performed or any one of these processes being killed externally. views etc. The cluster key is indexed using a cluster index and its value is stored only once for multiple tables in the cluster. It holds the most recently requested structural information about the database. Two processes waiting to update the rows of a table which are locked by the other process then deadlock arises. It holds the most recently requested structural information between users. indexes. 89. This will allow sharing of parsed SQL statements among concurrent users.) The server that access the database consists of SGA (Database buffer. What is a deadlock ? Explain. --One or more control files. What is a cluster Key ? The related columns of the tables are called the cluster key. Poor design of front-end application may cause this situation and the performance of server will reduce drastically. Shared SQL pool) SMON (System MONito) PMON (Process MONitor) LGWR (LoG Write) DBWR (Data Base Write) ARCH (ARCHiver) CKPT (Check Point) RECO Dispatcher User Process with associated PGS 87. What is mean by Program Global Area (PGA) ? It is area in memory that is used by a Single Oracle User Process.0) 84.. The Database contains --Multiple users/schemas --One or more rollback segments --One or more tablespaces --Data dictionary tables --User objects (table.

It is due to the data dictionary cache is too small. 93.User tablespace.Temporary purpose tablespace TEMP_USER . 98. This will create all definitions into newfile. What are the factors causing the reparsing of SQL statements in SGA? Due to insufficient Shared SQL pool size.Additional/Special Rollback segments. 4. What is dictionary cache ? Dictionary cache is information about the database objects stored in a data dictionary table. TOOLS1 . Drop necessary objects. How will you swap objects into a different table space for an existing database ? 1 Export the user 2. Perform import using the command imp system/manager file=export. 96. TOOLS .Static tables used for standard operations INDEXES . Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Monitor the ratio of the reloads takes place while executing SQL statements. List the Optional Flexible Architecture (OFA) of Oracle database ? or How can we organize the tablespaces in Oracle database to have maximum performance ? SYSTEM .Data dictionary tables.dmp indexfile=newrite. 99.com . DATA . If the ratio is greater than 1then increase the SHARED_POOL_SIZE. How will you force database to use particular rollback segment ? SET TRANSACTION USE ROLLBACK SEGMENT rbs_name.Standard Operations Rollback Segments. So that they can be used in roll forward operations during database recoveries. What is a data segment ? Data segment are the physical areas within a database block in which the data associated with tables and clusters are stored. What is meant by redo log buffer ? Changes made to entries are written to the on-line redo log files.Indexes of static tables used for standard operations. 94. they will first brought to redo log buffers in SGA and LGWR will write into files frequently. Run the script newfile. 125 91. RBS .Indexes for Standard operational tables. What is Database Buffers ? Database buffers are cache in the SGA used to hold the data blocks that are read from the data segments in the database such as tables. USERS . 3. 95. LOG_BUFFER parameter will decide the size.sql after altering the tablespaces.sql. 92. 5. INDEXES1 .Tools table.Standard operational tables.ORA decides the size. Before writing them into the redo log files. Import from the backup for the necessary objects. DATA2 . By increasing the SHARED_POOL_SIZE parameter we can optimize the size of Data Dictionary Cache.sql. TEMP . RBS1.Temporary tablespace for users.RBS2 . What is meant by recursive hints ? Number of times processes repeatedly query the dictionary table is called recursive hints.Indexes for tools table. indexes and clusters DB_BLOCK_BUFFERS parameter in INIT. 97.

ora file and Start database) 4) Create other tablespaces (RBS) for rollback segments. What is the significance of having storage clause ? We can plan the storage for a table as how much initial extents are required. 103.row date (multiple rows may exists) PCTEREE (% of free space for row updation in future) 105. What is the functionality of SYSTEM table space ? To manage the database level transactions such as modifications of the data dictionary table that record information about the free space usage. Row size also reduces no of rows per block. 2) Create a Second Rollback Segment name R0 in the SYSTEM tablespace. 3) Make new rollback segment available (After shutdown. 107. how much % should leave free for managing row updations etc. modify init. Free extents are periodically coalesces with the neighboring free extent in Ver 7. of rows per block? PCTFREE parameter. What is meant by free extent ? A free extent is a collection of continuous free blocks in tablespace. How does Space allocation take place within a block ? Each block contains entries as follows Fixied block header Variable block header Row Header. How will you create multiple rollback segments in a database ? 1) Create a database which implicitly creates a SYSTEM Rollback Segment in a SYSTEM tablespace. 108.0. 104.0 and Ver 7. 5) Deactivate Rollback Segment R0 and activate the newly created rollback segments. of extents is based on the optimal size) Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 101.0 ? Free extents cannot be merged together in Ver 6. When a segment is dropped its extents are reallocated and are marked as free.com . How the space utilisation takes place within rollback segments ? It will try to fit the transaction in a cyclic fashion to all existing extents. Once it found an extent is in use then it forced to acquire a new extent (No. 106. 107. 126 100. how much can be extended next.0 102.Which parameter in Storage clause will reduce no.. What is the OPTIMAL parameter ? It is used to set the optimal length of a rollback segment. What is the role of PCTFREE parameter is Storage clause ? This is used to reserve certain amount of space in a block for expansion of rows. How free extents are managed in Ver 6.

Allocate Sufficient temporary storage. 6) RBS chooses its oldest inactive segment. Calculate the average number rows that can fit in a block Calculate the number of blocks and bytes required for the table. 2) An entry is made in the RES header for new transactions entry 3) Transaction acquires blocks in an extent of RBS 4) The entry attempts to wrap into second extent.Rollback Segment is on-line. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. PARTLY AVAILABLE . 113. This prevents other user using Rollback segments. 1) Transaction Begins. 7) Oldest inactive segment is eliminated.Contains data from an unresolved transaction involving a distributed database. List the sequence of events when a large transaction that exceeds beyond its optimal value when an entry wraps and causes the rollback segment to expand into another extend. 2) A single transaction may wipeout all avaliable free space in the Rollback Segment Tablespace. None is available. 111. 127 109. 110. AVAILABLE . How will you monitor the space allocation ? By quering DBA_SEGMENT table/view. 8) RBS extents 9) The Data dictionary table for space management are updated.Rollback Segment available but not on-line.com . How will you monitor rollback segment status ? Querying the DBA_ROLLBACK_SEGS view IN USE . 5) The RBS checks to see if it is part of its OPTIMAL size. 112. 114.Contains data but need recovery or corupted. How will you estimate the space required by non-clustered tables? Calculate the total header size Calculate the available data space per data block Calculate the combined column lengths of the average row Calculate the total average row size. How can we plan storage for very large tables ? Limit the number of extents in the table Separate Table from its indexes. 10) Transaction Completes.Rollback Segment off-line INVALID . so that the RBS must extent.Rollback Segment Dropped. NEEDS RECOVERY . Why query fails sometimes ? 1) Rollback segment dynamically extent to handle larger transactions entry loads. OFF-LINE .

118. 119. What is meant by Redo Log file mirrorring ? How it can be achieved? Process of having a copy of redo log files is called mirroring. ora file by adding new control file. What is advantage of having disk shadowing/ Mirroring? Shadow set of disks save as a backup in the event of disk failure. What is hit ratio ? It is a measure of well the data cache buffer is handling requests for data. Improved performance because most OS support volume shadowing can direct file I/O request to use the shadow set of files instead of the main set of files.Hits Misses)/ Logical Reads. 122. add 10 % additional space to calculate the initial extent size for a working table. 117. Each Rollback Segment entry must be completed within one rollback segment. What is a Rollback segment entry? It is the set of before image data blocks that contain rows that are modified by a transaction. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. If any one group fails then database automatically switch over to next group. This reduces I/O load on the main set of disks. In most Operating System if any disk failure occurs it automatically switchover to place of failed disk. system files ? Yes.Physical Reads . so that LGWR will automatically writes them to all the members of the current on-line redo log group. It degrades performance. 115. It will be used to maintain internal consistency and guide recovery operations. Hit Ratio = (Logical Reads . A single rollback segment can have multiple rollback segment entries. Disk Corruption will be very less. I/O will be improved because Oracle is bye-passing the kernnel which writing into disk. What is a Control file ? Database's overall physical architecture is maintained in a file called control file. 128 After arriving the calculation.name Restart the database. How to implement the multiple control files for an existing database ? Shutdown the database Copy one of the existing control file to new location Edit config. What is use of Rollback Segments in Database? They allow the database to maintain read consistency between multiple transactions.com . 121. It is possible to use raw devices as data files and what is the advantages over file. 120. 116. Multiple copies of control files are advisable. This can be achieved by creating group of log files together.

updates to and deletes of rows as well as columns larger than a single datablock. 132. SYSTEM user account . When procedure executed it will execute the privilege of procedures owner. What are the database administrator’s utilities available? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What is user Account in Oracle database? A user account is not a physical structure in Database but it is having important relationship to the objects in the database and will be having certain privileges. When will be a segment released ? When Segment is dropped. 129. SYS user account . 127. When Shrink (RBS only) When truncated (TRUNCATE used with drop storage option) 124. 2) Trailling nulls and length bytes are not stored. can cause fragmentation an chained row pieces.com . What are disadvantages of having raw devices ? We should depend on export/import utility for backup/recovery (fully reliable) The tar command cannot be used for physical file backup. What are the roles and user accounts created automatically with the database ? DBA . 128. 129 123.It has all the system privileges for the database and additional tables and views that display administrative information and internal tables and views used by oracle tools are created using this username. What are the dictionary tables used to monitor a database spaces? DBA_FREE_SPACE DBA_SEGMENTS DBA_DATA_FILES. 130. instead we can use dd command which is less flexible and has limited recoveries. 131. List the factors that can affect the accuracy of the estimations ? 1) The space used transaction entries and deleted records does not become free immediately after completion due to delayed cleanout. 3)Inserts of. Instead grant the ability to access the procedures that access the tables. All of the basetables and views for the database's dictionary are store in this schema and are manipulated only by ORACLE. Users cannot access tables except via the procedure.role contains all database system privileges.The DBA role will be assigned to this account. How will you enforce security using stored procedures? Don't grant user access directly to tables within the application.

Perform any operating system specific steps (optional) 4.ora file. Switch the databse's archiving mode. Shutdown the database instance. PROCESSES .To determine the no of buffers in the buffer cache in SGA.This allows DBA to monitor and control an ORACLE database. 2. This can be used for tuning the database. 137. What are the minimum parameters should exist in the parameter file (init.It is string that specifies the network domain where the database is created. Start up a new instance and mount but do not open the databse.ora) ? DB NAME . What is a trace file and how is it created? Each server and background process can write an associated trace file. 133.List of control filenames of the database. DB_DOMAIN . Assign each role to group of users. SQL * Loader. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Export (EXP) and Import (imp) utilities allow you to move existing data in ORACLE format to and from ORACLE database. Also optionally LICENSE_MAX_SESSIONS. 135. How can you enable automatic archiving? 1) Shut the database 2) Backup the database 3) Modify/Include LOG_ARCHIVE_START_TRUE in init. When an internal error is detected by a process or user process. What are roles ? How can we implement roles ? Roles are the easiest way to grant and manage common privileges needed by different groups of database users.ora file.com . Backup the database 3. ROLLBACK_SEGMENTS . How can we specify the Archived log file name format and destination ? By setting the following values in init. LICENSE_SESSION_WARNING and LICENSE_MAX_USERS. it dumps information about the error to its trace. 134. The global database name is identified by setting these parameters (DB_NAME & DB_DOMAIN) CONTORL FILES . DB_BLOCK_BUFFERS . What are the steps to switch a database's archiving mode between NO ARCHIVELOG and ARCHIVELOG mode ? 1.It loads data from standard operating system files (Flat files) into ORACLE database tables.To determine number of operating system processes that can be connected to ORACLE concurrently. 136. 5. This will simplify the job of assigning privileges to individual users. redo log files and control files and control file while database creation.Must set to a text string of no more than 8 characters and it will be stored inside the datafiles. If name is not mentioned then default name will be used. 4) Start up the database. 130 SQL * DBA . 138. Creating roles and assigning provies to roles. The value should be 5 (background process) and additional 1 for each user.List of rollback segments an ORACLE instance acquires at database startup.

146. . 142. How can we reduce the network traffic ? . .If simple snapshot used then a snapshot log can be used to send the changes to the snapshot tables. . %s . The file name created is arch 0001 are if %S is used. It is stored in the same database as master table and is only available for simple snapshots. When will the data in the snapshot log be used ? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. What dynamic data replication? Updating or Inserting records in remote database through database triggers. Joins. 147. We can join tables in snapshots by creating a complex snapshots that will based on the master tables. . 141. snapshots ? . What are the options available to refresh snapshots? COMPLETE . What is snapshots? Snapshot is an object used to dynamically replicate data between distributed databases at specified time intervals.Using remote procedure calls. . 145.to validate the structure of the object.com . 148. . Differentiate simple and complex.table. FORCE .0 they are read only. It should be created before creating snapshots. or cluster: .to collect statisties about object used by the optimizer and store them in the data dictionary. FAST .Default value.Tables are completely regenerated using the snapshot’s query and the master tables every time the snapshot referenced.Replication of data in distributed environment. It may fail if remote database is having any problem.Using snapshots to replicate data.A complex snapshots contain at least any one of the above. What is snapshot log? It is a table that maintains a record of modifications to the master table in a snapshot. sub-query or snapshot of operations. CONNECT BY clauses. %T . 139.A simple snapshot is based on a query that does not contains GROUP BY clauses.Log sequence number and is zero left paded. 131 LOG_ARCHIVE_FORMAT = arch %S/s/T/tarc (%S .to identify migrated and chained rows of the table or cluster. If possible it performs a FAST refresh. What is the use of ANALYZE command ? To perform one of these function on an index. 140.Thread number lef-zero-paded and %t - Thread number not padded). How can you Enforce Referential Integrity in snapshots? Time the references to occur when master tables are not in use.to delete statistics about the object used by object from the data dictionary. Perform the reference the manually immediately locking the master tables. 149. LOG_ARCHIVE_DEST = path.Log sequence number not padded. otherwise it will perform a complete refresh. In ver 7. 143. What are the various type of snapshots? Simple and Complex.

Cumulative backup . Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.Complete database Incremental . 155. Value is 'Y' or 'N'. Database uses a two phase commit.All on-line redo log files. 4) The master table name should be less than or equal to 23 characters. What is the use of FILE option in EXP command ? To give the export file name. All Archive log. The following files need to be backed up.Only affected table from the last cumulative date/full backup date.All Data files. .Hot Backups (Archive log) 152. 151. (The table name created will be MLOGS_tablename. What is cold backup? What are the elements of it? Cold backup is taking backup of all physical files after normal shutdown of database. 153. it should be not be already available ) 2) After giving table privileges. 3) We cannot specify snapshot log name because oracle uses the name of the master table in the name of the database objects that support its snapshot log. For this the ARCHIVELOG mode should be enabled.. . 158 . All data files.All Control files. What is the use of COMPRESS option in EXP command ? Flag to indicate whether export should compress fragmented segments into single extents. . What is hot backup and how it can be taken? Taking backup of archive log files when database is open. What are the different methods of backing up oracle database ? . and trigger name will be TLOGS name). .Only affected tables from last incremental date/full backup date. 132 1) We must be able to create a after row trigger on table (i.com . What is the use of GRANT option in EXP command ? A flag to indicate whether grants on databse objects will be exported or not. 157. 150.e. What are the different kinds of export backups? Full back . We need to take.ora files (Optional) 154. redo log files. What are the benefits of distributed options in databases ? Database on other servers can be updated and those transactions can be grouped together with others in a logical unit. Export utility is used for taking backup and Import utility is used to recover from backup. What is a logical backup? Logical backup involves reading a set of database records and writing them into a file.Logical Backups .Cold Backups . All control files.The init. 156.

What is the use of CONSISTENT (Ver 7) option in EXP command ? A flag to indicate whether a read consistent version of all the exported objects should be maintained. 166. 163. What is the use of INCTYPE option in EXP command ? Type export should be performed COMPLETE. What is the use of RECORD option in EXP command ? For Incremental exports. If 'N' only DDL statements for the databse objects will be created. 161. 160. INCREMENTAL.com . What is the use of TABLES option in EXP command ? List of tables should be exported. 167. 133 159. 162. 169. What is the use of OWNER option in EXP command ? List of table accounts should be exported. What is the use of PARFILE option in EXP command ? Name of the parameter file to be passed for export. the flag indirects whether a record will be stores data dictionary tables recording the export. 165. 168. What is the use of ANALYSE ( Ver 7) option in EXP command ? A flag to indicate whether statistical information about the exported objects should be written to export dump file. 170. What is use of LOG (Ver 7) option in EXP command ? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. CUMULATIVE. What is the use of RECORD LENGTH option in EXP command ? Record length in bytes. 164. What is the use of FULL option in EXP command ? A flag to indicate whether full databse export should be performed. What is the use of ROWS option in EXP command ? Flag to indicate whether table rows should be exported. What is the use of CONSTRAINTS option in EXP command ? A flag to indicate whether constraints on table need to be exported. 171. What is the use of INDEXES option in EXP command ? A flag to indicate whether indexes on tables will be exported.

Transactional Control : COMMIT & ROLLBACK Session Control : ALTERSESSION & SET ROLE System Control : ALTER SYSTEM.TRUNCATE. Data Manipulation Language : INSERT. What is the use of GRANT option in IMP command ? A flag to indicate whether grants on database objects will be imported. What is the Subquery ? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.REVOKE. 174.DELETE. What is a join? Explain the different types of joins? Join is a query which retrieves related columns or rows from multiple tables.com . Non-Equi Join . Self Join . What are the types of SQL Statement ? Data Definition Language : CREATE. If this is set to 'N' then only DDL for database objects will be exectued. 181.Joining two tables in such a way that query can also retrive rows that do not have corresponding join value in the other table. 176. 175. What is the use of IGNORE option in IMP command ? A flag to indicate whether the import should ignore errors encounter when issuing CREATE commands. 178. What is the use of INDEXES option in IMP command ? A flag to indicate whether import should import index on tables or not.DROP. What is the use of SHOW option in IMP command ? A flag to indicate whether file content should be displayed or not.Joining two tables by equating two common columns. 179.NO AUDIT & COMMIT. 134 The name of the file which log of the export will be written.Joining two tables by equating two common columns. 173.Joining the table with itself.EXPLAIN PLAN & SELECT.What is the use of FILE option in IMP command ? The name of the file from which import should be performed. 172. Equi Join . 180. What is the use of ROWS option in IMP command ? A flag to indicate whether rows should be imported. What is a transaction ? Transaction is logical unit between two commits and commit and rollback. 177.UPDATE. Outer Join .LOCK TABLE.ALTER.

Difference between SUBSTR and INSTR ? INSTR (String1.(m)). SUBSTR (String1 n. blockno. What is correlated sub-query ? Correlated sub_query is a sub_query which has reference to the main query. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. rownumber are the components of ROWID. LONG and LONG RAW. 187. ename from emp where. RAW. TYPE rec RECORD is to be used whenever query returns columns of different table or views and variables. The search begins from nth position of string1.g.m) SUBSTR returns a character string of size m in string1. MINUS .String2(n. 182. select empno.returns all rows selected by either query. What is difference between % ROWTYPE and TYPE RECORD ? % ROWTYPE is to be used whenever query returns a entire row of a table or view. 188. NUMBER. 184. 190. DATE. starting from nth postion of string1. 186. UNION . What is ON DELETE CASCADE? When ON DELETE CASCADE is specified ORACLE maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or unique key value is removed. What is Referential Integrity ? Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the referenced table. 135 Subquery is a query whose return values are used in filtering conditions of the main query.returns all distinct rows selected by either query UNION ALL . What are the data types allowed in a table ? CHAR. What is ROWID ? ROWID is a pseudo column attached to each row of a table.including all duplicates. Explain UNION. INSTR returns the position of the mth occurrence of the string 2 in string1. 183. 185. It is 18 character long. 189.UNION ALL. INTERSECT ? INTERSECT returns all distinct rows selected by both queries.com .MINUS. VARCHAR2. e.returns all distinct rows selected by the first query but not by the second. Explain Connect by Prior? Retrives rows in hierarchical order.

For triggers related to DELETE only OLD. procedure and functions are stored ? User_objects.column_name and NEW.empno% type. What are advantages fo Stored Procedures ? Extensibility. Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ? Why ? It is not possible.Modularity.column_name values only available. Explain the usage of WHERE CURRENT OF clause in cursors ? WHERE CURRENT OF clause in an UPDATE. done using Integarity Constraints. e_rec c1 %ROWTYPE. if you use COMMIT of ROLLBACK in a trigger.ename emp ename %type ). Maintainability and one time compilation. 191. 193. What is Raise_application_error ? Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user defined error messages from stored sub-program or database trigger. User_Source and User_error.column_name. For triggers related to INSERT only NEW. 136 E. TYPE r_emp is RECORD (eno emp. 199.deptno from emp. 195.column_name NEW.com . For triggers related to UPDATE only OLD. What happens if a procedure that updates a column of table X is called in a database trigger of the same table ? Mutation of table occurs. What are two virtual columns available during database trigger execution ? The table columns are referred as OLD. done using Database triggers. 196. e_rec emp% ROWTYPE cursor c1 is select empno. Where the Pre_defined_exceptions are stored ? In the standard package. Write the order of precedence for validation of a column in a table ? I.column_name values only available. Name the tables where characteristics of Package. 194. 192.column_name values only available. it affects logical transaction processing. Reusability. 198. As triggers are defined for each table. I & ii. ii. 197. 200. SNAPSHOT is used for Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.DELETE statement refers to the latest row fetched from a cursor.g.

b] Data validation at entry line. 205. b] False 204. b] False 206. c] Both A & B. In a CLIENT/SERVER environment . d] None of the above 203. Why is it better to use an INTEGRITY CONSTRAINT to validate data in a table than to use a STORED PROCEDURE ? a] Because an integrity constraint is automatically checked while data is inserted into or updated in a table while a stored procedure has to be specifically invoked b] Because the stored procedure occupies more space in the database than a integrity constraint definition c] Because a stored procedure creates more network traffic than a integrity constraint definition 209. d] All of the above. Databases overall structure is maintained in a file called a] Redolog file. c] Shared_Pool_Size.ora parameter file DB_BLOCK_SIZE. 137 a] Synonym. c] System server. Constraints cannot be exported through EXPORT command a] True. b] Table space. 210. b] A client/server model increases developer. These following parameters are optional in init. d] None of the above 208. b] Complex snapshots. d] Neither A nor B 202. What does DLL stands for ? a] Dynamic Language Library b] Dynamic Link Library c] Dynamic Load Library Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. which of the following would not be done at the client ? a] User interface part. Which of the following is not an advantage of a client/server model ? a] A client/server model allows centralised control of data and centralised implementation of business rules. PROCESSES a] True. SET TRANSACTION USE ROLLBACK SEGMENT is used to create user Objects in a particular Tablespace a] True. b] Data file. b] Processes.com .s productivity c] A client/server model is suitable for all applications d] None of the above. b] False 207. c] Responding to user events. d] Dynamic data replication 201. c] Control file. We can create SNAPSHOTLOG for a] Simple snapshots. Transactions per rollback segment is derived from a] Db_Block_Buffers.

Dedicated server configuration is Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Size of Tablespace can be increased by a] Increasing the size of one of the Datafiles b] Adding one or more Datafiles c] Cannot be increased d] None of the above 214. A set of Dictionary tables are created a] Once for the Entire Database b] Every time a user is created c] Every time a Tablespace is created d] None of the above 216. A Transaction ends a] Only when it is Committed b] Only when it is Rolledback c] When it is Committed or Rolledback d] None of the above 218. A database trigger doesnot apply to data loaded before the definition of the trigger a] TRUE b] FALSE Ans : A 220. A Database Procedure is stored in the Database a] In compiled form b] As source code c] Both A & B d] Not stored 219. 138 d] None of the above 211. All datafiles related to a Tablespace are removed when the Tablespace is dropped a] TRUE b] FALSE 213.com . Datadictionary can span across multiple Tablespaces a] TRUE b] FALSE 217. What is a trigger a] A piece of logic written in PL/SQL b] Executed at the arrival of a SQL*FORMS event c] Both A & B d] None of the above 212. Multiple Tablespaces can share a single datafile a] TRUE b] FALSE 215.

Which of the following is not correct about User_Defined Exceptions ? a] Must be declared Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.One user process c] One server process . What will be the value of svar after the execution ? a] Error b] 10 c] 5 d] None of the above 223. Which of the following does not affect the size of the SGA a] Database buffer b] Redolog buffer c] Stored procedure d] Shared pool 222.One user process d] Many server processes . c] deptname dept. Which of the following is NOT VALID is PL/SQL a] Bool boolean. Which of the following is not correct about an Exception ? a] Raised automatically / Explicitly in response to an ORACLE_ERROR b] An exception will be raised when an error occurs in that block c] Process terminates after completion of error sequence. End. 139 a] One server process . 224. b] NUM1. d] A Procedure or Sequence of statements may be processed. Declare fvar number := null.Many user processes 221. Which of the following is TRUE 1] Host variables are declared anywhere in the program 2] Host variables are declared in the DECLARE section a] Only 1 is TRUE b] Only 2 is TRUE c] Both 1 & 2are TRUE d] Both are FALSE Ans : B 221.Many user processes b] Many server processes .dname%type. d] date1 date := sysdate 222. svar number := 5 Begin goto << fproc>> if fvar is null then << fproc>> svar := svar + 5 end if.com . NUM2 number.

PL/SQL supports datatype(s) a] Scalar datatype b] Composite datatype c] All of the above d] None of the above 261. 227. Is it possible to use Transactional control statements in Database Triggers ? a] Yes b] No 229.com . Which of the following is not correct about the "TABLE" datatype ? a] Can contain any no of columns b] Simulates a One-dimensional array of unlimited size Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. 140 b] Must be raised explicitly c] Raised automatically in response to an Oracle error d] None of the above 225. A Stored Procedure is a a] Sequence of SQL or PL/SQL statements to perform specific function b] Stored in compiled form in the database c] Can be called from all client environmets d] All of the above 226. Find the ODD datatype out a] VARCHAR2 b] RECORD c] BOOLEAN d] RAW 262. Which of the following statement is false a] Any procedure can raise an error and return an user message and error number b] Error number ranging from 20000 to 20999 are reserved for user defined messages c] Oracle checks Uniqueness of User defined errors d] Raise_Application_error is used for raising an user defined error. Is it possible to Enable or Disable a Database trigger ? a] Yes b] No 230. Is it possible to open a cursor which is in a Package in another procedure ? a] Yes b] No 228.

What is the Result of the following 'VIK'||NULL||'RAM' ? a] Error b] VIK RAM c] VIKRAM d] NULL 267. SUBSTR(‘SQUARE ANS ALWAYS WORK HARD’.. Which of the following is NOT VALID in PL/SQL ? a] Select . Declare a number := 5. Begin if a > b AND a < c then a := c * a. What will be the value of 'a' after execution ? a] 50 b] NULL c] 5 d] None of the above 268.6) will return a] ALWAY b} S ALWA c] ALWAYS d] WAYS W Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. c number := 10.14. Find the ODD one out of the following a] OPEN b] CLOSE c] INSERT d] FETCH 264. 141 c] Column datatype of any Scalar type d] None of the above 263.. Which of the following is not correct about Cursor ? a] Cursor is a named Private SQL area b] Cursor holds temporary results c] Cursor is used for retrieving multiple rows d] SQL uses implicit Cursors to retrieve rows 265. End. b number := null. into b] Update c] Create d] Delete 266. Does the Database trigger will fire when the table is TRUNCATED ? a] Yes b] No 269. end if.com .

Which of the following is not correct about a View ? a] To protect some of the columns of a table from other users b] Ocuupies data storage space c] To hide complexity of a query d] To hide complexity of a calculations 275.'J'. EMPNO ENAME SAL A822 RAMASWAMY 3500 A812 NARAYAN 5000 A973 UMESH A500 BALAJI 5750 Using the above data Select count(sal) from Emp will retrieve a] 1 b] 0 c] 3 as Group functions does not consider nulls d] None of the above 278.'0123456789ABCDPQRST'.com . 142 270. Is it possible to modify a Datatype of a column when column contains data ? a] Yes b] No 274. REPLACE('JACK AND JUE'. The Data Manipulation Language statements are a] INSERT b] UPDATE c] SELECT d] All of the above 277.'0123456789') will return a] 333234 b] 333333 c] 234333 d] None of the above 273. TRANSLATE('333SQD234'. Which is not part of the Data Definiton Language ? a] CREATE b] ALTER c] ALTER SESSION 276. will it accept the rows that are inserted with SYSDATE ? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.'BL') will return a] JACK AND BLUE b] BLACK AND JACK c] BLACK AND BLUE d] None of the above 271. If an UNIQUE KEY constraint on DATE column is created.

EFFECTIVE. SYSTEM TABLESPACE can be made off-line a] Yes Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. Delete d] All of the above 280. Update.com . Database mounted & Database opened c] Database opened. What built-in subprogram is used to manipulate images in image items ? a] Zoom_out b] Zoom_in' c] Image_zoom d] Zoom_image 281. File mounted. :SYSTEM. Can we pass RECORD GROUP between FORMS ? a] Yes b] No 282. Instance started & Database opened 287. What are the different events in Triggers ? a] Define. SHOW_ALERT function returns a] Boolean b] Number c] Character d] None of the above 283. What is built_in Subprogram ? a] Stored procedure & Function b] Collection of Subprogram c] Collection of Packages d] None of the above 286 . Instance started b] Instance started. What SYSTEM VARIABLE is used to refer DATABASE TIME ? a] $$dbtime$$ b] $$time$$ c] $$datetime$$ d] None of the above 284. 143 a] Will b] Won't 279. Comment c] Insert. Create b] Drop. Instance started & file mounted d] Files mounted.DATE varaible is a] Read only b] Read & Write c] Write only d] None of the above 285. Sequence of events takes place while starting a Database is a] Database opened.

144 b] No 288. SNAPSHOTS cannot be refreshed automatically a] TRUE b] FALSE 292. SMON process is used to write into LOG files a] TRUE b] FALSE 290. EXP command is used a] To take Backup of the Oracle Database b] To import data from the exported dump file c] To create Rollback segments d] None of the above 291. ENQUEUE_RESOURCES parameter information is derived from a] PROCESS or DDL_LOCKS & DML_LOCKS b] LOG BUFFER c] DB_BLOCK_SIZE d] DB_BLOCK_BUFFERS 289. PROCESS a} TRUE b] FALSE 294.ora parameter file DB_BLOCK_SIZE. The User can set Archive file name formats a] TRUE b] FALSE 293. It is very difficult to grant and manage common priveleges needed by different groups of database users using roles a] TRUE b] FALSE 297.com . The following parameters are optional in init. NOARCHIEVELOG parameter is used to enable the database in Archieve mode a] TRUE b] FALSE 295. Constraints cannot be exported through Export command? a] TRUE b] FALSE 296. The status of the Rollback segment can be viewed through a] DBA_SEGMENTS b] DBA_ROLES c] DBA_FREE_SPACES d] DBA_ROLLBACK_SEG Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.

com .sql or utlxpls. Use the explain plan set statement_id = 'tst1' into plan_table for a SQL statement Look at the explain plan with utlxplp. What command would you use to create a backup control file? Alter database backup control file to trace. 309. If a change was necessary then I would use the alter system set db_cache_size command. What type of index should you use on a fact table? A Bitmap index.sql. 304.Instance startup MOUNT . What is a mutating table error and how can you get around it? Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. STARTUP NOMOUNT .INI d] None of the above 300. 306. Give two examples of referential integrity constraints. 303.The database is opened 307. Give the two types of tables involved in producing a star schema and the type of data they hold. Where would you look for errors from the database engine? In the alert log. Explicitly we can assign transaction to a rollback segment a] TRUE B] FALSE 299. What file is read by ODBC to load drivers ? a] ODBC. 301. A fact table contains measurements while dimension tables will contain data that will help describe the fact tables. Faster access to data blocks in a table. How would you go about generating an EXPLAIN plan? Create a plan table with utlxplan. Give the reasoning behind using an index. A primary key and a foreign key.INI b] ODBC. Fact tables and dimension tables.DLL c] ODBCDRV. 305. Give the stages of instance startup to a usable state where normal users may access it.sql 308. How would you go about increasing the buffer cache hit ratio? Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. 302.The database is mounted OPEN . 145 298.

com . Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. eg SELECT field1 from table1 X WHERE field2>(select avg(field2) from table1 Y where field1=X.field1). 314. This can also be used to generate explain plan output. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. When looking at v$sysstat you see that sorts (disk) is high.) Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. How do you prevent Oracle from giving you informational messages during and after a SQL statement execution The SET options FEEDBACK and VERIFY can be set to OFF. However if you also have chained rows this can hurt performance. 310. 312. (The subquery in a correlated subquery is revaluated for every row of the table or view named in the outer query. This indicates you need to tune the sort area parameters in the initialization files. Is this bad? Why or why not. The usual fix involves either use of views or temporary tables so the database is selecting from one while updating the other. 315. The major sort are parameter is the SORT_AREA_SIZE parameter. Is this bad or good? If bad -How do you correct it? If you get excessive disk sorts this is bad. 313. REDO LOG. 311. What is a CO-RELATED SUBQUERY A CO-RELATED SUBQUERY is one that has a correlation name as table or view designator in the FROM clause of the outer query and the same correlation name as a qualifier of a search condition in the WHERE clause of the subquery. Explain the use of TKPROF? What initialization parameter should be turned on to get full TKPROF output? The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. DATA. Multiple extents in and of themselves aren?t bad. TEMPORARY and INDEX segments. 146 This happens with triggers. How do you set up tablespaces during an Oracle installation? You should always attempt to use the Oracle Flexible Architecture standard or another partitioning scheme to ensure proper separation of SYSTEM. ROLLBACK. A tablespace has a table with 30 extents in it. It occurs because the trigger is trying to update a row it is currently using.

.If not why. 323... What will be the query to find it.. END.This is because the storage for a cursor variable has to be allocated using Pro*C or OCI with version 2. What are various privileges that a user can grant to another user SELECT CONNECT RESOURCE 318. In PL/SQL 2. 321. 324.... What a SELECT FOR UPDATE cursor represent.2.an OUT parameter cannot return a value. a cursor variable points a row which cannot be stored in a two-dimensional PL/SQL table. WHERE CURRENT OF CLAUSE in an UPDATE or declaration statement. '\' Should be used before '%'.A function has to return a value.com . UPDATE students SET current_credits=current_credits+v_numcredits WHERE CURRENT OF X.. There is a '%' sign in one field of a column. LOOP SELECT num_credits INTO v_numcredits FROM classes WHERE dept=123 and course=101. Can cursor variables be stored in PL/SQL tables. Can a function take OUT parameters. A convenient way of modifying the rows is done by a method with two parts: the FOR UPDATE clause in the cursor declaration.FROM.2.. 320.UPDATE[OF column-reference][NOWAIT] The processing done in a fetch loop modifies the rows that have been retrieved by the cursor. What 'WHERE CURRENT OF ' clause does in a cursor.2 cursor variables cannot be declared in a package. No..the only means of passing a cursor variable to a PL/SQL block is via bind variable or a procedure parameter. No. 322. 319..If not why. What are various constraints used in SQL NULL NOT NULL CHECK DEFAULT 317....FOR.. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.IN or EXISTS EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value. 147 316. How you were passing cursor variables in PL/SQL 2. END LOOP COMMIT. SELECT.If yes how. Which is more faster .

If a tablespace has a default pctincrease of zero what will this cause (in relationship to the smon process) The SMON process won?t automatically coalesce its free space fragments.but not other form triggers.COBOL. 148 325. 330. Difference between database triggers and form triggers.PL/SQL blocks are executed like other DML statements. Oracle Call Interface is a method of accesing database from a 3GL program. What are ORACLE PRECOMPILERS. If you see contention for library caches how can you fix it Increase the size of the shared pool. Uses--No precompiler is required.PASCAL. c) Can manipulate data stored in Oracle tables via SQL Can manipulate data in Oracle tables as well as variables in forms. 331.the language in which pl/sql is embedded is known as the host language. Can be fired only from the form that define the trigger. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.C++. d) Can be fired from any session executing the triggering DML statements. This form of PL/SQL is known as embedded pl/sql. FORTRAN.. 328..Pro*Cobol. e) Can cause other database triggers to fire. Using ORACLE PRECOMPILERS . a) Data base trigger(DBT) fires when a DML operation is performed on a data base table. If you see statistics that deal with "undo" what are they really talking about Rollback segments and associated structures.PL/1 AND ADA.. What are its uses.ENABLE function? 1.SQL statements and PL/SQL blocks can be contained inside 3GL programs written in C. What is OCI.The output must be compiled and linked with this library to creater an executable. What is the maximum buffer size that can be specified using the DBMS_OUTPUT.Form trigger(FT) Fires when user presses a key or navigates between fields on the screen b) Can be row level or statement level No distinction between row level and statement level. 326. The OCI library provides -functions to parse SQL statemets -bind input variables -bind output variables -execute statements -fetch the results 327. The prcompiler translates the embedded SQL and pl/sql ststements into calls to the precompiler runtime library.com .Can cause other database triggers to fire.000. The Precompilers are known as Pro*C.000 329.

until freed What is the problem T he archive destination is probably full. 338. The redo logs should not be on raw devices on UNIX if it can be avoided. /* Declare a record with same structure as cursor variable. 336. HP-UX Error: 2: No such file or directory What is the probable cause? The Oracle instance is shutdown that they are trying to access. Create a cursor type . 333. If yes how. then it is fragmented.com .REF CURSOR and declare a cursor variable of that type. If the MAX_DATAFILES is set to low. How can you tell if a tablespace has excessive fragmentation If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files. backup the archive logs and remove them and the archiver will re-start. Connect internal only. You attempt to add a datafile and get: ORA-01118: cannot add anymore datafiles: limit of 40 exceeded What is the problem and how can you fix it When the database was created the db_files parameter in the initialization file was set to 40. */ TYPE company_curtype IS REF CURSOR RETURN company%ROWTYPE. 335. Can cursor variables be stored in PL/SQL tables. you will have to rebuild the control file to increase it before proceeding. 334. /* Declare a cursor variable of that type. DECLARE /* Create the cursor type.dbf file. You can shutdown and reset this to a higher value. Users from the PC clients are getting the following error stack: ERROR: ORA-01034: ORACLE not available ORA-07318: smsget: open error when opening sgadef. Can you use a commit statement within a database trigger? Yes. The following message is received: ORA-00257 archiver is stuck. restart the instance. Users aren?t being allowed on the system. 337. */ company_curvar company_curtype. How many redo logs should you have and how should they be configured for maximum recoverability You should have at least three groups of two redo logs with the two logs each on a separate disk spindle (mirrored by Oracle). up to the value of MAX_DATAFILES as specified at database creation. 149 332. If not why? Yes. if you are using autonomous transactions in the Database triggers. */ Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail.

’j'). BEGIN /* Open the cursor variable. Discuss row chaining. 150 company_rec company%ROWTYPE. This is done via a standalone utility that transforms the PL/SQL source code into portable binary object code (somewhat larger than the original). It can be reduced by setting the storage parameters on the table to appropriate values. This way you can distribute software without having to worry about exposing your proprietary algorithms and methods. The syntax is: wrap iname=myscript.yyy 99. Just be careful. How can I protect my PL/SQL source code? PL/SQL V2. Display the number value in Words? select sal.1 one can use the DBMS_SQL package to execute dynamic SQL statements. available with Oracle7. /* Fetch from the cursor variable. This results in the row chaining to another block. 4712 BC and sp means to spell out.’jsp’)) from emp. A scalar data type like number or varchar can’t be used but a record type may evaluate to a scalar value. Eg: CREATE OR REPLACE PROCEDURE DYNSQL AS cur integer. GENERAL INTERVIEW QUESTIONS 342. Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. there is no "decode" command available. 341. */ CLOSE company_curvar. END. /* Close the cursor object associated with variable.(to_char(to_date(sal. SQL*Plus and SQL*DBA will still understand and know how to execute such scripts. 339.2. implements a binary wrapper for PL/SQL programs to protect the source code. It can be corrected by export and import of the effected table. how does it happen? How can you reduce it? How do you correct it? Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won?t fit in the remaining block space. */ FETCH company_curvar INTO company_rec.com . associating with it a SQL statement. 340.2.Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure ? How ? From PL/SQL V2. the number of days since January 1. J means Julian day. Can we use a scalar data type as return type? The return type of a cursor variable can be %ROWTYPE or record_name%TYPE or a record type or a ref cursor type.sql oname=xxxx. What should be the return type for a cursor variable. */ OPEN company_curvar FOR SELECT * FROM company.

This allows the user to determine if the optimizer would use the index. It is part of the Oracle Enterprise Manger Tuning Pack (Virtual Index Wizard). the DBA_SEGMENTS view will not show an entry for this.e.CLOSE_CURSOR(cur). Virtual indexes.com .EXECUTE(cur). once implemented.'CREATE TABLE X (Y DATE)'. this functionality is not intended for standalone usage.It allows the CBO to evaluate the potential new index for a selected SQL statement by building an explain plan that is aware of the potential new index. BEGIN cur := DBMS_SQL. i.PARSE(cur. rc := DBMS_SQL. and are meant for a very specific purpose.OPEN_CURSOR.As per Oracle. 345. DBMS_SQL. as the name suggests are pseudo-indexes that will not behave the same way that normal indexes behave. A virtual index has no segment pegged to it. Let’s Make World a better place to work ! Oracle Frequently asked Question Gurpreet Singh g6singh@hotmail. DBMS_SQL. Virtual Indexes are another undocumented feature used by Oracle. 151 rc integer. DBMS_SQL. Oracle handles such indexes internally and few required dictionary tables are updated so that the optimizer can be made aware of its presence and generate an execution plan considering such indexes.A virtual index is created in a slightly different manner than the normal indexes.. The virtual index wizard functionality allows the user to test a potential new index prior to actually building the new index in the database. END.NATIVE).