Questions
Questions
Questions
How can you tell if an UPDATE updated no rows? SQL%NOTFOUND. How can you tell if a SELECT returned no rows. NO_DATA_FOUND exception. What is a cursor ? ( Basic)
Name or handle to a private SQL area where Oracle parses and fetches query results.
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. 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 How to control how many cursors are open ?(Intermediate)
Set OPEN_CURSORS parameter in initialization parameters It deallocates space (Unless REUSE STORAGE is given).
Infinite Loop How will you stop an infinite loop without closing the program?
use the EXIT statement This will stop the looping and proceed to the next executable statement. or EXIT WHEN condition
Indexed Select Statement How can we find the select statement is indexed or not?
AUTO Trace - Trace only command Use "Explain Plan" command SQL> SET AUTOTRACE ON TRACEONLY SELECT *FROM emp WHERE emp_name 'ABC'; 2. Using EXPLAIN PLAN SQL> EXPLAIN PLAN for SELECT *FROM emp WHERE emp_name 'ABC';
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.
Procedure in package perfomes fastly over normal procedure, Explain. 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.
Package Function You have a package called A and one function in that packgae called XYZ. If you need to call that function in second packaged B, How will you call?
Yes You can call the function from another package as below: Pakagename.funciton name 46. You have just compiled a PL/SQL package but got errors, how would you view the errors? SHOW ERRORS
How many types of database triggers can be specified on a table? What are they ?
There are a total of 12 possible types: 3 Statements (INSERT UPDATE OR DELETE) 2Timing (BEFORE or AFTER) 2 Levels (ROW or STATEMENT) So 3*2*2 12 possible types. A table can have 12 triggers defined on it. There are five types of database triggers Row Level Trigger Statement Level Trigger Instead of Trigger Schema Trigger Database Trigger A trigger may be a 1. DML Trigger on tables 2. Instead of triggers on views 3. System triggers on database or schema Based on the way it executes statements triggers are of two types 1. Statement leve trigger 2. Row level trigger A trigger fires for three actions 1. Insert 2. Delete 3.Update and the trigger can the fired 1. Before action 2. After action.
When you need to disable all triggers on the a particular table. Which command accomplishes this?
Answer: ALTER TABLE <Table_Name> DISABLE ALL TRIGGERS; 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.
What's SQL*Loader SQL*Loader is a product for moving data in external files into tables in an Oracle database. To load data from external files into an Oracle database, two types of input must be provided to SQL*Loader : the data itself and the control file. The control file describes the data to be loaded. It describes the Names and format of the data files, Specifications for loading data and the Data to be loaded (optional). Invoking the loader sqlload username/password controlfilename <options>.
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