Database Interview Questions
PL/SQL Interview Questions
- Which of the following statements is true about implicit cursors?
- Implicit cursors are used for SQL statements that are not named.
- Developers should use implicit cursors with great care.
- Implicit cursors are used in cursor for loops to handle data processing.
- Implicit cursors are no longer a feature in Oracle.
- Which of the following is not a feature of a cursor FOR loop?
- Record type declaration.
- Opening and parsing of SQL statements.
- Fetches records from cursor.
- Requires exit condition to be defined.
PL/SQL Interview Questions II
- What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs?
- Only one
- All that apply
- All referenced
- None
- For which trigger timing can you reference the NEW and OLD qualifiers?
- Statement and Row
- Statement only
- Row only
- Oracle Forms trigger
- Read the following code:
CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END;
Which set of statements will successfully invoke this function within SQL*Plus?
- VARIABLE g_yearly_budget NUMBER
EXECUTE g_yearly_budget := GET_BUDGET(11);
- VARIABLE g_yearly_budget NUMBER
PL/SQL Interview Questions III
- Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed?
- When the transaction is committed
- During the data manipulation statement
- When an Oracle supplied package references the trigger
- During a data manipulation statement and when the transaction is committed
- Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus?
- DBMS_DISPLAY
- DBMS_OUTPUT
- DBMS_LIST
- DBMS_DESCRIBE
- What occurs if a procedure or function terminates with failure without being handled?
- Any DML statements issued by the construct are still pending and can be committed or rolled back.
Oracle DBA Interview Questions
- Explain the difference between a hot backup and a cold backup and the benefits associated with each. - A hot backup is basically taking a backup of the database while it is still up and running and it must be in archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require being in archive log mode. The benefit of taking a hot backup is that the database is still available for use while the backup is occurring and you can recover the database to any point in time. The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you are taking cold backups the database does not require being in archive log mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.
Interview Questions on Oracle
- What’s the command to see the current user name? Sql> show user;
- What’s the command to change the SQL prompt name?
SQL> set sqlprompt “database-1 > ”
database-1 >
database-1 > - How do you switch to DOS prompt from SQL prompt? SQL> host
- How do I eliminate duplicate rows in an Oracle database?
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);