What are Pseudo columns? - They are not actual columns.

They are like Functions without arguments. - They typically give a different value for each row. - Examples: ROWNUM, NEXTVAL, ROWID, VERSION_STARTTIME Why use Truncate over Delete while deleting all rows? - Truncate is efficient. Triggers are not fired. - It deallocates space (Unless REUSE STORAGE is given). What is a ROWID composed of ? - It's a hexadecimal string representing the address of a row. Prior to Oracle 8, it's a restricted rowid comprising block.row.file. Extended rowid ( the default on higher releases) comprises data object number as well ( comprising the segment number ). What is the use of a ROWID? - Retrieve data faster with ROWID. - Shows you the physical arrangement of rows in the table. - Also unique identifier for each row. Can rows from two different tables have the same ROWID? - Possible, if they are in a Cluster What is ROWNUM and ROW_NUMBER? - ROWNUM is a pseudocolumn which is the number assigned to each row retrieved. - ROW_NUMBER is an analytic function which does something similar, but has all the capabilities of PARTITION BY and ORDER BY clauses.. What is an inline view? - It's not a schema object - It's a subquery in the FROM clause with an alias that can be used as a view within the SQL statement. What are Nested and Correlated sub queries? - The subquery used in WHERE clause is a nested subquery. - If this subquery refers to any column in the parent statement, it becomes a correlated subquery. How do you retrieve a dropped table in 10g? - FLASHBACK table <tabname> to BEFORE DROP What is an index-organized table? - The physical arrangement of rows of this table changes with the indexed column. - It's. in-short, a table stored like an index itself.

What are the types of triggers? There are 12 types of triggers in PL/SQL that consist of combinations of the BEFORE. Describe the use of %ROWTYPE and %TYPE in PL/SQL %ROWTYPE allows you to associate a variable with an entire table row. They can be used to hold values for use in later queries or calculations. It occurs because the trigger is trying to update a row it is currently using. 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. Tell some new features in PL/SQL in 10g (Intermediate to Advanced) . AFTER. or RECORD. REGEXP_REPLACE.INDICES OF . The %TYPE associates a variable with a single column type.Compile time warnings . REGEXP_INSTR.What is a mutating table error and how can you get around it? This happens with triggers. TABLE. ROW. Instead of quoting single quotes twice everytime. In Oracle 8 they will be able to be of the %ROWTYPE designation.Conditional compilation . DELETE and ALL key words: BEFORE ALL ROW INSERT AFTER ALL ROW INSERT BEFORE INSERT AFTER INSERT etc. VALUES OF in FORALL lets you work on non-consecutive indices . give your .Quoting mechanism . and REGEXP_SUBSTR .BINARY_INTEGER made similar to PLS_INTEGER . UPDATE. The usual fix involves either use of views or temporary tables so the database is selecting from one while updating the other. 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.Improvement to native compilation . escribe the use of PL/SQL tables PL/SQL tables are scalar arrays that can be referenced by a binary integer. INSERT.Regular expression functions REGEXP_LIKE .

-Used commonly to generate Primary key values What is MERGE ? Combination of INSERT and UPDATE Tell some tips to avoid performance problems in PL/SQL. NATURAL.DYNAMIC WRAP using DBMS_DDL What is a sequence ? . You can modify body without invalidating dependent objects.Public/private procs.Global optimization enabled . Overhead of keeping a copy of OUT is avoided. used subsequently. INTEGER maintain precision and scale but not optimized for performance as additional checks are made to maintain precision and scale.Use BINARY_FLOAT. SCN_TO_TIMESTAMP. Body defines public constructs. additionally declares and defines Private constructs . .Use PLS_INTEGER for computation intensive code.Use FORALL instead of FOR.Improved Overloading .own delimiter to go on using single quotes.A database object that offers high-speed access to an integer value .!' .Encapsulation of code logic . . BINARY_DOUBLE .Reorder conditional tests to put least expensive ones first . functions.New datatypes BINARY_FLOAT.PLS_INTEGER range increased to 32bit . TIMESTAMP_TO_SCN .Implicit conversion between CLOB and NCLOB .Dependency simplified .Loaded once into memory . and use BULK COLLECT to avoid looping many times .Guaranteed to be unique (within that sequence).Minimize datatype conversions => Assign data to exact same type variables . .Flashback Query functions. variables What is a package spec and package body ? Why the separation ? . INTEGER as they have additional checks .Separation helps make development easier .Do not use subtypes like POSITIVE. NUMBER. Ex: q'!I'm a string. . BINARY_DOUBLE .Privileges to objects can be controlled .Spec declares public constructs.Tune SQL statements to avoid CPU overhead .Use NOCOPY for OUT and IN OUT if the original value need not be retained. you're a string.EXECUTE IMMEDIATE is faster than DBMS_SQL What are the advantages of Packages ? .Dependency is simplified. .

Here SQL%ISOPEN is false. because oracle automatically closed the implicit cursor after executing SQL statements.sal<=b..sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b. : 2. cursor_name%ROWCOUNT. like runtime construction of sql. Others Triggers . 11. SQL%ISOPEN Tips : 1.It has all the advantages of dynamic sql .Its advantage over EXECUTE IMMEDIATE is it can Describe objects .sal)) FROM EMP B WHERE a. SQL%ROWCOUNT. Implicit Cursor attributes Same as explicit cursor but prefixed by the word SQL SQL%Found. SQL%NOTFOUND. Enter value for n: 2 SAL --------3700 Any three PL/SQL Exceptions? Too_many_rows. DDL statements can be executed.What are the advantages and disadvantages of DBMS_SQL ? . Zero_Error. cursor_name%ISOPEN 10. Value_Error.sal). . Find out nth highest salary from emp table SELECT DISTINCT (a. cursor_name%NOTFOUND. All are Boolean attributes.It's kind of bulky and difficult compared to EXECUTE IMMEDIATE. No_Data_Found. Explicit Cursor attributes There are four cursor attributes used in Oracle cursor_name%Found.

o.LEVEL ARE PSEDUOCOLUMNS In pl/sql functions what is use of out parameter even though we have returnstatement. use procedures instead of functions. PRAGMA EXCEPTION_INIT (exception name. We can use OUT parameter in functions in order to return values but Return also is a MUST.g. These ROWNUM'S logically generated. After Statement o. NEXTVAL.k.Statement level trigger.k.k. It Is a 18 character hexma decimal value.k.k. oracle error number) Cursor Variable Restrictions u cannot declare cursor in package specification not allowed when using db links cannot use comparison operators cannot assign NULL cursor's values cannot be stored in table columns .Instead of trigger(created on views) ROWID : Every record in a database is uniquely identified by system generated value called Rowid.k.k.k. o. e.k. If WHEN clause is specified. To get an error message of a specific oracle error. o.CURRVAL. Row level trigger. o.nsert Update Delete Before Row o. These Rowid's are physically existence. After Row o.. o. the trigger fires according to the returned Boolean value.SYSDATE. then the trigger for each Row affected by the statement.k. ROWNUM : It is a pseduocolumn which generates the sequence of numeric values based on the position of the records in the output. Before Statement o. o. Best practice is that if you need multiple values.k. o.k. If FOR EACH ROW clause is specified. What is Pragma EXECPTION_INIT ? Explain the usage? The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. o.

E. nested tables and varray cannot be use one where the other is expected cannot reference a cursor variable in cursor FOR LOOP cannot direclty goto any columns Reference Cursors Ref Cursor is cursor variable. e_rec emp% ROWTYPE cursor c1 is select empno. TYPE rec RECORD is to be used whenever query returns columns of different table or views and variables.g. It is useful in scenarios when result set is created in one program and the processing of the same in some other.g.ename emp ename %type ). % ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.empno% type.cannot be used with associative array. What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes? % TYPE provides the data type of a variable or a database column to that variable. e.deptno from emp. Ref cursors are used when we want to use the cursor which is not bound to a specific query. e_rec c1 %ROWTYPE. TYPE r_emp is RECORD (eno emp. What is difference between a Cursor declared in a procedure and Cursor declared in a package specification? A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package. might be written in different language. It is a pointer to a result set. firing the select is done in PL/SQL and the processing will be done in Java. the data type of a variable changes accordingly. The advantages are : I. Need not know about variable's data type ii. Cursor variables can be tied to many such type of compatible queries. What is PL/SQL table ? . If the database definition of a column in a table changes. A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures What is difference between % ROWTYPE and TYPE RECORD ? % ROWTYPE is to be used whenever query returns a entire row of a table or view.

What is COMPUTE? When we are trying to determine the sum of some columns in a result set we can use Compute. Select timestamps.. First. and therefore don?t exist in any persistent way. Second. END. FOR EXAMPLE DECLARE -. -. Remember that PL/SQL tables exist in memory only. obj_name. with use of autonomous_transaction parent transaction is seprated from child transaction and child transaction can be committed or rolled back without affecting parent transaction and that is how we can commit or rollback in triggers.name_name%TYPE INDEX BY BINARY_INTEGER. and these all have tendency to lock the rows for their operation. It is impor-tant for you to realize that they are not database tables. This function is used for reporting purpose.PL/SQL tables are PL/SQL?s way of providing arrays. -.Create the actual table CnameTab NameType. once a table type is created. you must define the table structure using the TYPE statement. Arrays are like tem-porary tables in memory and thus are processed very quickly. triggers are fired when any DML is performed on a table like insert update or delete.Table structure definition TYPE NameType IS TABLE OF Customer. This type of table is indexed by a binary integer counter (it cannot be indexed by another type of number) whose value can be referenced using the number of the index. A PL/SQL TABLE DECLARATION There are two steps in the declaration of a PL/SQL table. whereas Commit or Rollback when used releases the locks if any acquired by transaction. . BEGIN NULL. and DML statements cannot be issued against them. KnameTab NameType..this statement gives last executed time for procedure . thus in this state trigger gets confused either to lock the rows or to release the lock and goes to mutating stage.. you then declare the actual table. function & package. action_name from dba_audit_trail. disappearing after the session ends. owner. Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger? Why? we cannot use commit and rollback in triggers without using PRAGMA AUTONOMOUS_TRANSACTION.

LOCKS Data Locks protects data i. Dictionary Locks protects the structure of database object i. Share Update are synonymous with Row Share. . Row Exclusive same as Row Share but prohibits locking in shared mode. Exclusive Lock allows queries on locked table but no other activity is allowed.e. Shared Row Exclusive locks the whole table and allows users to look at rows in the table but prohibit others from locking the table in share or updating them. Table or Row lock. Share Lock allows concurrent queries but prohibits updates to the lockedtables. They are automatic. ensures table's structure does not change for the duration of the transaction.e. Internal Locks & Latches protects the internal database structures. Row Share allows concurrent access to the locked table but prohibits for a exclusive table lock.

Sign up to vote on this title
UsefulNot useful