Q.What is the purpose of database links in Oracle?
Database links are created to establish communication between different databases or different environments such as development, test and production of the same database. The database links are usually designed to be read-only to access other database information . They are also useful when you want to copy production data into test environment for testing.
Q. What is Oracle's data dictionary used for?
Data dictionary in Oracle contains information about all database objects such as tables, triggers, stored procedures, functions, indexes, constraints, views, users, roles, monitoring information, etc.
Q. Which data dictionary objects are used to retrieve the information about the following objects from a given schema? 1) tables 2) views 3) triggers 4) procedures 5) constraints 6) all of the above mentioned objects
The objects used are: a> user_tables or tabs b> user_views c> user_triggers d> user_procedures e> user_constraints f> user_objects
fferent SQL queries in the same PL/SQL program vs. design time declared explicit cursors with an association to only one query.
Q. You want to view top 50 rows from Oracle table. How do I this?
Use ROWNUM, the pseudo column in where clause as follows: Where rownum < 51
After complete execution of query and before displaying output of SQL query to the user oracle internally assigns sequential numbers to each row in the output. These numbers are held in the hidden column or pseudo column that is a ROWNUM column. Now it is so simple to apply the above logical condition, as you would have done to any other column of the table.
Q. How do you reference column values in BEFORE and AFTER insert and delete triggers?
The BEFORE and AFTER insert triggers can reference column values by new collection using keyword ":new.column name". The before and after delete triggers can reference column values by old collection using keyword ":old. column name".
Q. Can you change the inserted value in one of the columns in AFTER insert trigger code?
This is not possible as the column values supplied by the insert SQL query are already inserted into the table. If you try to assign new value to the column in AFTER insert trigger code then oracle error would be raised. To alter any values supplied by insert SQL query create BEFORE insert trigger.
Q. Explain use of SYSDATE and USER keywords.
SYSDATE is a pseudo column and refers to the current server system date. USER is a pseudo column and refers to the current user logged onto the oracle session. These values come handy when you want to monitor changes happening to the table.
Q. What is the difference between explicit cursor and implicit cursor?
When a single insert, delete or update statement is executed within PL/SQL program then oracle creates an implicit cursor for the same, executes the statement, and closes the cursor. You can check the result of execution using SQL%ROWCOUNT function.
Explicit cursors are created programmatically. The cursor type variable is declared and associated with SQL query. The program then opens a cursor, fetches column information into variables or record type variable, and closes cursor after all records are fetched. To check whether cursor is open or not use function SQL%ISOPEN and to check whether there are any records to be fetched from the cursor use function SQL%FOUND.
Q. Why does a query in Oracle run faster when ROWID is used as a part of the where clause?
ROWID is the logical address of a row - it is not a physical column. It is composed of file number, data block number and row number within data block. Therefore I/O time is minimized retrieving the row, resulting in a faster query.
Q. What type of exception will be raised in the following situations:
a> select..into statement returns more than one row.
b> select..into statement does not return any row.