You are on page 1of 32

1. 2. 3.

What are two methods of retrieving SQL? What cursor type do you use to retrieve multiple recordsets? What is the difference between a "where" clause and a "having" clause? - "Where" is a kind of restiriction statement. You use where clause to restrict all the data from DB.Where clause is using before result retrieving. But Having clause is using after retrieving the data.Having clause is a kind of filtering command. What is the basic form of a SQL statement to read data out of a table? The basic form to read data out of table is SELECT * FROM table_name; An answer: SELECT * FROM table_name WHERE xyz= whatever; cannot be called basic form because of WHERE clause.

4.

5.

What structure can you implement for the database to speed up table reads? - Follow the rules of DB tuning we have to: 1] properly use indexes ( different types of indexes) 2] properly locate different DB objects across different tablespaces, files and so on.3] create a special space (tablespace) to locate some of the data with special datatype ( for example CLOB, LOB and ) What are the tradeoffs with having indexes? - 1. Faster selects, slower updates. 2. Extra storage space to store indexes. Updates are slower because in addition to updating the table you have to update the index. What is a "join"? - join used to connect two or more tables logically with or without common field. What is "normalization"? "Denormalization"? Why do you sometimes want to denormalize? - Normalizing data means eliminating redundant information from a table and organizing the data so that future changes to the table are easier. Denormalization means allowing redundancy in a table. The main benefit of denormalization is improved performance with simplified data retrieval and manipulation. This is done by reduction in the number of joins needed for data processing. What is a "constraint"? - A constraint allows you to apply simple referential integrity checks to a table. There are four primary types of constraints that are currently supported by SQL Server: PRIMARY/UNIQUE - enforces uniqueness of a particular table column. DEFAULT - specifies a default value for a column in case an insert operation does not provide one. FOREIGN KEY validates that every value in a column exists in a column of another table. CHECK - checks that every value stored in a column is in some specified list. Each type of constraint performs a specific type of action. Default is not a constraint. NOT NULL is one more constraint which does not allow values in the specific column to be null. And also it the only constraint which is not a table level constraint. What types of index data structures can you have? - An index helps to faster search values in tables. The three most commonly used index-types are: - B-Tree: builds a tree of possible values with a list of row IDs that have the leaf value. Needs a lot of space and is the default index type for most databases. - Bitmap: string of bits for each possible value of the column. Each bit string has one bit for each row. Needs only few space and is very fast.(however, domain of value cannot be large, e.g. SEX(m,f); degree(BS,MS,PHD) - Hash: A hashing algorithm is used to assign a set of characters to represent a text string such as a composite of keys or partial keys, and compresses the underlying data. Takes longer to build and is supported by relatively few databases. What is a "primary key"? - A PRIMARY INDEX or PRIMARY KEY is something which comes mainly from database theory. From its behavior is almost the same as an UNIQUE INDEX, i.e. there may only be one of each value in this column. If you call such an INDEX PRIMARY instead of UNIQUE, you say something about

6. 7. 8.

9.

10.

11.

12.

your table design, which I am not able to explain in few words. Primary Key is a type of a constraint enforcing uniqueness and data integrity for each row of a table. All columns participating in a primary key constraint must possess the NOT NULL property. What is a "functional dependency"? How does it relate to database table design? Functional dependency relates to how one object depends upon the other in the database. for example, procedure/function sp2 may be called by procedure sp1. Then we say that sp1 has functional dependency on sp2. What is a "trigger"? - Triggers are stored procedures created in order to enforce integrity rules in a database. A trigger is executed every time a data-modification operation occurs (i.e., insert, update or delete). Triggers are executed automatically on occurance of one of the data-modification operations. A trigger is a database object directly associated with a particular table. It fires whenever a specific statement/type of statement is issued against that table. The types of statements are insert,update,delete and query statements. Basically, trigger is a set of SQL statements A trigger is a solution to the restrictions of a constraint. For instance: 1.A database column cannot carry PSEUDO columns as criteria where a trigger can. 2. A database constraint cannot refer old and new values for a row where a trigger can. Why can a "group by" or "order by" clause be expensive to process? - Processing of "group by" or "order by" clause often requires creation of Temporary tables to process the results of the query. Which depending of the result set can be very expensive. What is "index covering" of a query? - Index covering means that "Data can be found only using indexes, without touching the tables"

13.

14. 15.

16. What types of join algorithms can you have? 17. What is a SQL view? - An output of a query can be stored as a view. View acts like small table
which meets our criterion. View is a precomplied SQL query which is used to select data from one or more tables. A view is like a table but it doesnt physically take any space. View is a good way to present data in a particular format if you use that query quite often. View can also be used to restrict users from accessing the tables directly.

Oracle is based on RDBMS. SQL is Structured Query Language. SQL Server is another tool for RDBMS provided by MicroSoft.

why you need indexing ? where that is stroed and what you mean by schema object? For what purpose we are using view? We cant create an Index on Index.. Index is stoed in user_index table.Every object that has been created on Schema is Schema Object like Table,View etc.If we want to share the particular data to various users we have to use the virtual table for the Base table...So tht is a view.

indexing is used for faster search or to retrieve data faster from various table. Schema containing set of tables, basically schema means logical separation of the database. View is crated for faster retrieval of data. It's customized virtual table. we

can create a single view of multiple tables. Only the drawback is..view needs to be get refreshed for retrieving updated data.

Difference between Store Procedure and Trigger? we can call stored procedure explicitly. but trigger is automatically invoked when the action defined in trigger is done. ex: create trigger after Insert on this trigger invoked after we insert something on that table. Stored procedure can't be inactive but trigger can be Inactive. Triggers are used to initiate a particular activity after fulfilling certain condition.It need to define and can be enable and disable according to need. What is the advantage to use trigger in your PL? Triggers are fired implicitly on the tables/views on which they are created. There are various advantages of using a trigger. Some of them are:

Suppose we need to validate a DML statement(insert/Update/Delete) that modifies a table then we can write a trigger on the table that gets fired implicitly whenever DML statement is executed on that table.

Another reason of using triggers can be for automatic updation of one or more tables whenever a DML/DDL statement is executed for the table on which the trigger is created.

Triggers can be used to enforce constraints. For eg : Any insert/update/ Delete statements should not be allowed on a particular table after office hours. For enforcing this constraint Triggers should be used.

Triggers can be used to publish information about database events to subscribers. Database event can be a system event like Database startup or shutdown or it can be a user even like User loggin in or user logoff.

What the difference between UNION and UNIONALL? Union will remove the duplicate rows from the result set while Union all does'nt.

What is the difference between TRUNCATE and DELETE commands? Both will result in deleting all the rows in the table .TRUNCATE call cannot be rolled back as it is a DDL command and all memory space for that table is released back to

the server. TRUNCATE is much faster.Whereas DELETE call is an DML command and can be rolled back.

Which system table contains information on constraints on all the tables created yes, USER_CONSTRAINTS, system table contains information on constraints on all the tables created Explain normalization ? ?

Normalisation means refining the redundancy and maintain stablisation. there are four types of normalisation :

first normal forms, second normal forms, third normal forms and fourth Normal forms. How to find out the database name from SQL*PLUS command prompt? Select * from global_name;

This will give the datbase name which u r currently connected to..... What is the difference between SQL and SQL Server ? SQLServer is whereas Structured Query Language (SQL), pronounced "sequel", is a language that provides an interface to relational database systems. It was developed by IBM in the 1970s for use in System R. SQL is a de facto standard, as well as an ISO and ANSI standard. SQL is used to perform various operations on RDBMS. What is diffrence between Co-related sub query and nested sub query? Correlated subquery runs once for each row selected by the outer query. It contains a reference to a value from the row selected by the outer query. Nested subquery runs only once for the entire nesting (outer) query. It does not contain any reference to the outer query row. For example, an RDBMS just like oracle,DB2 from Microsoft

Correlated Subquery:

select e1.empname, e1.basicsal, e1.deptno from emp e1 where e1.basicsal = (select max(basicsal) from emp e2 where e2.deptno = e1.deptno)

Nested Subquery: select empname, basicsal, deptno from emp where (deptno, basicsal) in (select deptno, max(basicsal) from emp group by deptno)

WHAT

OPERATOR

PERFORMS

PATTERN

MATCHING?

Pattern matching operator is LIKE and it has to used with two attributes 1. % and

2. _ ( underscore )

% means matches zero or more characters and under score means mathing exactly one character

1)What 2) 3) What What

is

difference are

between in

Oracle Oracle in

and and and

MS MS MS

Access? Access? Access?

disadvantages

are

feratures&advantages

Oracle

Oracle's features for distributed transactions, materialized views and replication are not available with MS Access. These features enable Oracle to efficiently store data for multinational companies across the globe. Also these features increase scalability of applications based on Oracle. What is database?

A database is a collection of data that is organized so that itscontents can easily be accessed, managed and updated. open this

url : http://www.webopedia.com/TERM/d/database.html What is cluster.cluster index and non cluster index ?

Clustered Index:- A Clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table may have only one clustered index.Non-Clustered Index:- A Non-Clustered index is a special type of index in which the logical order of the index does not match the physical stored order

of the rows in the disk. The leaf nodes of a non-clustered index does not consists of the data pages. instead the leaf node contains index rows. How can i hide a particular table name of our schema?

you can hide the table name by creating synonyms. e.g) you can create a synonym y for table x

create synonym y for x;

What

is

difference

between

DBMS

and

RDBMS?

The main difference of DBMS & RDBMS is RDBMS have Normalization. Normalization means to refining the redundant and maintain the stablization.

the DBMS hasn't normalization concept. What are the advantages and disadvantages of primary key and foreign key in SQL? Primary key Advantages

1) It is a unique key on which all the other candidate keys are functionally dependent

Disadvantage

1) There can be more than one keys on which all the other attributes are dependent on.

Foreign Key Advantage

1)It allows refrencing another table using the primary key for the other table

Which date function is used to find the difference between two dates? datediff for Eg: select datediff (dd,'2-06-2007','7-06-2007')output is 5

Oracle Interview Questions and Answers : SQL 1. To see current user name Sql> show user; 2. Change SQL prompt name SQL> set sqlprompt Manimara > Manimara > Manimara > 3. Switch to DOS prompt SQL> host 4. 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); or SQL> delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from table_name tb where ta.dv=tb.dv); Example. 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.ename = b.ename); The output like, Empno Ename 101 Scott 102 Millor 103 Jiyo 104 Smith 5. How do I display row number with records? To achive this use rownum pseudocolumn with query, like SQL> SQL> select rownum, ename from emp; Output: 1 Scott 2 Millor 3 Jiyo 4 Smith 6. Display the records between two range select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start);

Enter value for upto: 10 Enter value for Start: 7 ROWNUM EMPNO ENAME ---------- --------- --------1 7782 CLARK 2 7788 SCOTT 3 7839 KING 4 7844 TURNER 7. I know the nvl function only allows the same data type(ie. number or char or date Nvl(comm, 0)), if commission is null then the text Not Applicable want to display, instead of blank space. How do I write the query? SQL> select nvl(to_char(comm.),'NA') from emp; Output : NVL(TO_CHAR(COMM),'NA') ----------------------NA 300 500 NA 1400 NA NA 8. Oracle cursor : Implicit & Explicit cursors Oracle uses work areas called private SQL areas to create SQL statements. PL/SQL construct to identify each and every work are used, is called as Cursor. For SQL queries returning a single row, PL/SQL declares all implicit cursors. For queries that returning more than one row, the cursor needs to be explicitly declared. 9. Explicit Cursor attributes There are four cursor attributes used in Oracle cursor_name%Found, cursor_name%NOTFOUND, cursor_name%ROWCOUNT, cursor_name%ISOPEN 10. Implicit Cursor attributes Same as explicit cursor but prefixed by the word SQL SQL%Found, SQL%NOTFOUND, SQL%ROWCOUNT, SQL%ISOPEN Tips : 1. Here SQL%ISOPEN is false, because oracle automatically closed the implicit cursor after executing SQL statements. : 2. All are Boolean attributes. 11. Find out nth highest salary from emp table SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal); Enter value for n: 2 SAL ---------

3700 12. To view installed Oracle version information SQL> select banner from v$version; 13. Display the number value in Words SQL> select sal, (to_char(to_date(sal,'j'), 'jsp')) from emp; the output like, 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. 14. 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 15. Which date function returns number value? months_between 16. Any three PL/SQL Exceptions? Too_many_rows, No_Data_Found, Value_Error, Zero_Error, Others 17. What are PL/SQL Cursor Exceptions? Cursor_Already_Open, Invalid_Cursor 18. Other way to replace query result null value with a text SQL> Set NULL N/A to reset SQL> Set NULL 19. What are the more common pseudo-columns? SYSDATE, USER , UID, CURVAL, NEXTVAL, ROWID, ROWNUM 20. What is the output of SIGN function? 1 for positive value,

0 for Zero, -1 for Negative value. 21. What is the maximum number of triggers, can apply to a single table? 12 triggers.

Oracle PLSQL Interview Questions. Additional Concepts Every Developer Should Know.
PL/SQL Demystified
The best way of learning something is by asking questions. That's why I've organized this hub in a question-answer format. The questions range from Basic to Advanced. I gave a concise answer too, only for quick reference and revision. For detailed answer to each question, refer to any Oracle PL/SQL online documentation. Some of these questions were actually asked in my Job Interviews in the US. I have added some others which I found interesting. Very useful to know. What is a cursor ? ( Basic) - Name or handle to a private SQL area where Oracle parses and fetches query results. How to control how many cursors are open ?(Intermediate) - Set OPEN_CURSORS parameter in initialization parameters. What is shared SQL ? (Intermediate) -Oracle recognizes similar statements. The SQL area is used many times for similar statements. What is Parsing ? (Intermediate) - Syntax checking, privileges checking, allocating Private SQL Area. What is the difference between anonymous blocks and stored procedures ? ( Basic) - Anonymous block is compiled only when called.

- Stored procedure is compiled and stored in database with the dependency information as well. - Former is PL/SQL code directly called from an application. Latter is stored in database. - Former has declare statement.Latter doesnt. What are the advantages of procedures ? ( Basic) - Loaded once and used many times - Performance better coz all SQL stmts are sent in one go from the application to the database - Security ( no object privileges are given directly ) - Invoker's rights possible - Data integrity, productivity What are standalone procedures ? (Basic) - Those that are not part of package How is a PL/SQL program stored in database ? (Advanced) - Parsed code is stored. It's called P-code How is a PL/SQL program executed ?(Advanced) - Prior to Oracle 9i, we have only bytecode and a virtual machine in the database runs it. Later versions have faster native code execution. - PL/SQL engine is the main component that executes procedural stmt and passes the SQL to the SQL statement executor. What are the advantages and disadvantages of DBMS_SQL ? (Intermediate) - It has all the advantages of dynamic sql .. like runtime construction of sql, DDL statements can be executed. - Its advantage over EXECUTE IMMEDIATE is it can Describe objects - It's kind of bulky and difficult compared to EXECUTE IMMEDIATE. What is a package spec and package body ? Why the separation ? ( Basic)

- Spec declares public constructs. Body defines public constructs, additionally declares and defines Private constructs - Separation helps make development easier - Dependency is simplified. You can modify body without invalidating dependent objects. What are the advantages of Packages ? ( Basic) - Encapsulation of code logic - Privileges to objects can be controlled - Loaded once into memory , used subsequently. - Dependency simplified - Public/private procs, functions, variables How do you handle exceptions for bulk operations ? (Intermediate) - Use the SAVE EXCEPTIONS clause ( FORALL index IN bound_clause SAVE EXCEPTIONS LOOP ... END LOOP ) - Use 'Exceptions When Others' to handle the exceptions - SQL%BULK_EXCEPTIONS(i).ERROR_CODE, SQL%BULK_EXCEPTIONS(i).ERROR_INDEX SQL%BULK_EXCEPTIONS.COUNT Tell some tips to avoid performance problems in PL/SQL. (Intermediate to Advanced) - Use FORALL instead of FOR, and use BULK COLLECT to avoid looping many times - Tune SQL statements to avoid CPU overhead - Use NOCOPY for OUT and IN OUT if the original value need not be retained. Overhead of keeping a copy of OUT is avoided. - Reorder conditional tests to put least expensive ones first - Minimize datatype conversions => Assign data to exact same type variables

- Use PLS_INTEGER for computation intensive code. NUMBER, INTEGER maintain precision and scale but not optimized for performance as additional checks are made to maintain precision and scale. - Do not use subtypes like POSITIVE, NATURAL, INTEGER as they have additional checks - Use BINARY_FLOAT, BINARY_DOUBLE - EXECUTE IMMEDIATE is faster than DBMS_SQL How to know PL/SQL compile parameters ?(Advanced) - SHOW PARAMETERS PLSQL - ALL_PLSQL_OBJECT_SETTINGS What is MERGE ?( Basic) - Combination of INSERT and UPDATE Tell some new features in PL/SQL in 10g (Intermediate to Advanced) - Regular expression functions REGEXP_LIKE , REGEXP_INSTR, REGEXP_REPLACE, and REGEXP_SUBSTR - Compile time warnings - Conditional compilation - Improvement to native compilation - BINARY_INTEGER made similar to PLS_INTEGER - INDICES OF , VALUES OF in FORALL lets you work on non-consecutive indices - Quoting mechanism . Instead of quoting single quotes twice everytime, give your own delimiter to go on using single quotes. Ex: q'!I'm a string, you're a string.!' - Flashback Query functions. SCN_TO_TIMESTAMP, TIMESTAMP_TO_SCN - Implicit conversion between CLOB and NCLOB - Improved Overloading

- New datatypes BINARY_FLOAT, BINARY_DOUBLE - Global optimization enabled - PLS_INTEGER range increased to 32bit - DYNAMIC WRAP using DBMS_DDL What is a sequence ? (Basic) - A database object that offers high-speed access to an integer value - Guaranteed to be unique (within that sequence). -Used commonly to generate Primary key values

21. How would you determine the time zone under which a database was operating? select DBTIMEZONE from dual; 22. 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. 23. What command would you use to encrypt a PL/SQL application? WRAP 24. 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.

25. 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. 26. Name three advisory statistics you can collect. Buffer Cache Advice, Segment Level Statistics, & Timed Statistics 27. Where in the Oracle directory tree structure are audit traces placed? In unix $ORACLE_HOME/rdbms/audit, in Windows the event viewer

28. Explain materialized views and how they are used. Materialized views are objects that are reduced sets of information that have been summarized, grouped, or aggregated from base tables. They are typically used in data warehouse or decision support systems. 29. When a user process fails, what background process cleans up after it? PMON 30. What background process refreshes materialized views? The Job Queue Processes. 31. How would you determine what sessions are connected and what resources they are waiting for?

Use of V$SESSION and V$SESSION_WAIT 32. Describe what redo logs are. 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. 33. How would you force a log switch? ALTER SYSTEM SWITCH LOGFILE; 34. Give two methods you could use to determine what DDL changes have been made. You could use Logminer or Streams

35. What does coalescing a tablespace do? Coalescing is only valid for dictionarymanaged tablespaces and de-fragments space by combining neighboring free extents into large single extents. 36. 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. 37. Name a tablespace automatically created when you create a database. The SYSTEM tablespace.

38. When creating a user, what permissions must you grant to allow them to connect to the database? Grant the CONNECT to the user. 39. How do you add a data file to a tablespace? ALTER TABLESPACE ADD DATAFILE SIZE 40. How do you resize a data file? ALTER DATABASE DATAFILE RESIZE ; 41. What view would you use to look at the size of a data file? DBA_DATA_FILES

42. What view would you use to determine free space in a tablespace? DBA_FREE_SPACE 43. How would you determine who has added a row to a table? Turn on fine grain auditing for the table. 44. How can you rebuild an index? ALTER INDEX REBUILD; 45. Explain what partitioning is and what its benefit is. Partitioning is a method of taking large tables and indexes and splitting them into smaller, more manageable pieces. 46. You have just compiled a PL/SQL

package but got errors, how would you view the errors? SHOW ERRORS 47. How can you gather statistics on a table? The ANALYZE command. 48. How can you enable a trace for a session? Use the DBMS_SESSION.SET_SQL_TRACE or Use ALTER SESSION SET SQL_TRACE = TRUE; 49. What is the difference between the SQL*Loader and IMPORT utilities?

These two Oracle utilities are used for loading data into the database. 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. 50. Name two files used for network connection to a database. TNSNAMES.ORA and SQLNET.ORA Technical - UNIX Every DBA should know something about the operating system that the database will be running on. The questions here are related to UNIX but you should equally be able to answer questions related to common Windows

environments. 1. How do you list the files in an UNIX directory while also showing hidden files? ls -ltra 2. How do you execute a UNIX command in the background? Use the "&" 3. What UNIX command will control the default file permissions when files are created? Umask 4. Explain the read, write, and execute permissions on a UNIX directory. Read allows you to see and list the

directory contents. Write allows you to create, edit and delete files and subdirectories in the directory. Execute gives you the previous read/write permissions plus allows you to change into the directory and execute programs or shells from the directory. 5. the difference between a soft link and a hard link? A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system. 6. Give the command to display space usage on the UNIX file system.

df -lk 7. Explain iostat, vmstat and netstat. Iostat reports on terminal, disk and tape I/O activity. Vmstat reports on virtual memory statistics for processes, disk, tape and CPU activity. Netstat reports on the contents of network data structures. 8. How would you change all occurrences of a value using VI? Use :%s///g 9. Give two UNIX kernel parameters that effect an Oracle install SHMMAX & SHMMNI

10. Briefly, how do you install Oracle software on UNIX. Basically, set up disks, kernel parameters, and run orainst. PL/SQL interview qiuestions
By admin | May 8, 2004 1. Which of the following statements is true about implicit cursors? 1. Implicit cursors are used for SQL statements that are not named. 2. Developers should use implicit cursors with great care. 3. Implicit cursors are used in cursor for loops to handle data processing. 4. Implicit cursors are no longer a feature in Oracle. 2. Which of the following is not a feature of a cursor FOR loop? 1. Record type declaration. 2. Opening and parsing of SQL statements. 3. Fetches records from cursor. 4. Requires exit condition to be defined. 3. A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes? 1. Use employee.lname%type. 2. Use employee.lname%rowtype. 3. Look up datatype for EMPLOYEE column on LASTNAME table and use that. 4. Declare it to be type LONG. 4. Which three of the following are implicit cursor attributes? 1. %found 2. %too_many_rows 3. %notfound 4. %rowcount 5. %rowtype 5. If left out, which of the following would cause an infinite loop to occur in a simple loop? 1. LOOP 2. END LOOP

6.

7.

8.

9.

3. IF-THEN 4. EXIT Which line in the following statement will produce an error? 1. cursor action_cursor is 2. select name, rate, action 3. into action_record 4. from action_table; 5. There are no errors in this statement. The command used to open a CURSOR FOR loop is 1. open 2. fetch 3. parse 4. None, cursor for loops handle cursor opening implicitly. What happens when rows are found using a FETCH statement 1. It causes the cursor to close 2. It causes the cursor to open 3. It loads the current row values into variables 4. It creates the variables to hold the current row values Read the following code:

10. CREATE OR REPLACE PROCEDURE find_cpt 11. (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER) 12. IS 13. BEGIN 14. IF v_cost_per_ticket > 8.5 THEN 15. SELECT cost_per_ticket 16. INTO v_cost_per_ticket 17. FROM gross_receipt 18. WHERE movie_id = v_movie_id; 19. END IF; 20. END;

Which mode should be used for V_COST_PER_TICKET? 1. IN 2. OUT 3. RETURN 4. IN OUT 21. Read the following code:
22. CREATE OR REPLACE TRIGGER update_show_gross 23. {trigger information} 24. BEGIN 25. {additional code} 26. END;

The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3. Which trigger information will you add? 1. WHEN (new.cost_per_ticket > 3.75)

2. WHEN (:new.cost_per_ticket > 3.75 3. WHERE (new.cost_per_ticket > 3.75) 4. WHERE (:new.cost_per_ticket > 3.75) 27. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs? 1. Only one 2. All that apply 3. All referenced 4. None 28. For which trigger timing can you reference the NEW and OLD qualifiers? 1. Statement and Row 2. Statement only 3. Row only 4. Oracle Forms trigger 29. Read the following code:
30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT INTO FROM WHERE END; yearly_budget v_yearly_budget studio id = v_studio_id;

RETURN v_yearly_budget;

Which set of statements will successfully invoke this function within SQL*Plus? 1. VARIABLE g_yearly_budget NUMBER EXECUTE g_yearly_budget := GET_BUDGET(11); 2. VARIABLE g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11); 3. VARIABLE :g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11); 4. VARIABLE g_yearly_budget NUMBER :g_yearly_budget := GET_BUDGET(11);

43. CREATE OR REPLACE PROCEDURE update_theater 44. (v_name IN VARCHAR v_theater_id IN NUMBER) IS 45. BEGIN 46. UPDATE theater 47. SET name = v_name 48. WHERE id = v_theater_id; 49. END update_theater;

50. When invoking this procedure, you encounter the error:


ORA-000: Unique constraint(SCOTT.THEATER_NAME_UK) violated.

How should you modify the function to handle this error? 1. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section. 2. Handle the error in EXCEPTION section by referencing the error code directly. 3. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception. 4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement. 51. Read the following code:
52. 53. 54. 55. 56. 57. 58. 59. 60. CREATE OR REPLACE PROCEDURE calculate_budget IS v_budget studio.yearly_budget%TYPE; BEGIN v_budget := get_budget(11); IF v_budget < 30000 THEN set_budget(11,30000000); END IF; END;

You are about to add an argument to CALCULATE_BUDGET. What effect will this have? 1. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution. 2. The SET_BUDGET function will be marked invalid and must be recompiled before the next execution. 3. Only the CALCULATE_BUDGET procedure needs to be recompiled. 4. All three procedures are marked invalid and must be recompiled. 61. Which procedure can be used to create a customized error message? 1. RAISE_ERROR 2. SQLERRM 3. RAISE_APPLICATION_ERROR 4. RAISE_SERVER_ERROR 62. The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger? 1. ALTER TRIGGER check_theater ENABLE; 2. ENABLE TRIGGER check_theater; 3. ALTER TABLE check_theater ENABLE check_theater; 4. ENABLE check_theater; 63. Examine this database trigger
64. CREATE OR REPLACE TRIGGER prevent_gross_modification 65. {additional trigger information} 66. BEGIN 67. IF TO_CHAR(sysdate, DY) = MON 68. THEN 69. RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday);

70. 71. END;

END IF;

This trigger must fire before each DELETE of the GROSS_RECEIPT table. It should fire only once for the entire DELETE statement. What additional information must you add? 1. BEFORE DELETE ON gross_receipt 2. AFTER DELETE ON gross_receipt 3. BEFORE (gross_receipt DELETE) 4. FOR EACH ROW DELETED FROM gross_receipt 72. Examine this function:
73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. CREATE OR REPLACE FUNCTION set_budget (v_studio_id IN NUMBER, 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 TRUEl; ELSE RETURN FALSE; END IF; COMMIT; END;

Which code must be added to successfully compile this function? 1. Add RETURN right before the IS keyword. 2. Add RETURN number right before the IS keyword. 3. Add RETURN boolean right after the IS keyword. 4. Add RETURN boolean right before the IS keyword. 88. 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 89. 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

90. 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 91. 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. 92. Examine this code
93. BEGIN 94. theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year; 95. 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. 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. 96. A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hardcoded 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

You might also like