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

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 Folks, check out http://hubpages.com/hub/oracle_sql_plsql for more questions. What does Opening a cursor do ? - It executes the query and identifies the Result set What does Fetching a cursor do ? - It reads the Result Set row by row. What does Closing a cursor do ? - It clears the private SQL area and de-allocates the memory.

What are Cursor Variables ? - Also called REF CURSORS. - They are not tied to a single SQL. They point to any SQL area dynamically. - Advantage is : You can declare variables at Client side and open them Server side. You can thus centralize data retrieval. Why use Cursor Variables? - You can pass cursor RESULT SETS between PL/SQL stored programs and clients. What are SQLCODE and SQLERRM ? - Oracle Error code and detailed error message - They are actually functions with no arguments, that can be used only in procedural statements ( not SQL) What are Pseudocolumns ? - 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 subqueries ? - 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 are PSPs? - PL/SQL Server Pages. Web pages developed in PL/SQL 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 is an implicit cursor? - Oracle opens an implicit cursor to process each SQL statement not associated with an explicit cursor. Name a few implicit cursor attributes. - %FOUND, %ROWCOUNT, %NOTFOUND, %ISOPEN, %BULK_ROWCOUNT, %BULK_EXCEPTIONS