Oracle PL/SQL Programming and Database Administration
Test your knowledge of Oracle PL/SQL programming, database triggers, stored procedures, and database administration concepts. Includes questions on PL/SQL blocks, exceptions, indexes, and database constraints.
Questions
Script component Can have only one Input flow and zero or more Output flows.
- True
- False
Object is Valid Data type of SSIS Variable.
- True
- False
You created stored procedure DELETE_TEMP_TABLE that uses dynamic SQL to remove a table in your schema. You have granted the EXECUTE privilege to user A on this procedure. When user A executes the DELETE_TEMP_TABLE procedure, under whose privileges are the operations performed by default?
- SYS privileges
- Your privileges
- Public privileges
- User A’s privileges
Which code can you use to ensure that the salary is not increased by more than 10% at a time nor is it ever decreased?
- ALTER TABLE emp ADD CONSTRAINT ck_sal CHECK (sal BETWEEN sal AND sal*1.1);
- CREATE OR REPLACE TRIGGER check_sal BEFORE UPDATE OF sal ON emp - 6 - FOR EACH ROW WHEN (new.sal < old.sal OR new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, ‘Do not decrease salary not increase by more than 10%’); END;
- CREATE OR REPLACE TRIGGER check_sal BEFORE UPDATE OF sal ON emp WHEN (new.sal < old.sal OR new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, ‘Do not decrease salary not increase by more than 10%’); END;
- CREATE OR REPLACE TRIGGER check_sal AFTER UPDATE OR sal ON emp WHEN (new.sal < old.sal OR -new.sal > old.sal * 1.1) BEGIN RAISE_APPLICATION_ERROR ( - 20508, ‘Do not decrease salary not increase by more than 10%’); END;
Examine the code and state which of the following options is correct? CREATE OR REPLACE PACKAGE bonus IS g_max_bonus NUMBER := .99; FUNCTION calc_bonus (p_emp_id NUMBER) RETURN NUMBER; FUNCTION calc_salary (p_emp_id NUMBER) RETURN NUMBER; END; / CREATE OR REPLACE PACKAGE BODY bonus IS v_salary employees.salary%TYPE; v_bonus employees.commission_pct%TYPE; FUNCTION calc_bonus (p_emp_id NUMBER) RETURN NUMBER - 7 - IS BEGIN SELECT salary, commission_pct INTO v_salary, v_bonus FROM employees WHERE employee_id = p_emp_id; RETURN v_bonus * v_salary; END calc_bonus FUNCTION calc_salary (p_emp_id NUMBER) RETURN NUMBER IS BEGIN SELECT salary, commission_pct INTO v_salary, v_bonus FROM employees WHERE employees RETURN v_bonus * v_salary + v_salary; END cacl_salary; END
- You can call the BONUS.CALC_SALARY packaged function from an INSERT command against the EMPLOYEES table.
- You can call the BONUS.CALC_SALARY packaged function from a SELECT command against the EMPLOYEES table.
- You can call the BONUS.CALC_SALARY packaged function form a DELETE command against the EMPLOYEES table.
- You can call the BONUS.CALC_SALARY packaged function from an UPDATE command against the EMPLOYEES table.
Which statement is valid when removing procedures?
- Use a drop procedure statement to drop a standalone procedure.
- Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package specification.
- Use a drop procedure statement to drop a procedure that is part of a package. Then recompile the package body.
- For faster removal and re-creation, do not use a drop procedure statement. Instead, recompile the procedure using the alter procedure statement with the REUSE SETTINGS clause.
You need to create a trigger on the EMP table that monitors every row that is changed and places this information into the AUDIT_TABLE. What type of trigger do you create?
- FOR EACH ROW trigger on the EMP table.
- Statement-level trigger on the EMP table.
- FOR EACH ROW trigger on the AUDIT_TABLE table
- Statement-level trigger on the AUDIT_TABLE table
Which of the following do not help you execute multiple PL/SQL programs simultaneously?
- Oracle Advanced Queuing
- DBMS_JOB
- DBMS_SQL
- Pipelined Functions
In a PL/SQL block, a variable is declared as NUMBER without an initial value. What will its value be when it is first used in the executable section of the PL/SQL block?
- NULL
- 0
- Results in a compilation error
- An exception will be raised
Which of the following queries return the names of programs (without duplication) defined in the currently-connected schema whose source contains a call to DBMS_OUTPUT.PUT_LINE (assume that this program name does not appear inside comments)?
- SELECT name FROM USER_DEPENDENCIES WHERE referenced_name = 'DBMS_OUTPUT.PUT_LINE'
- SELECT name from ALL_SOURCE WHERE owner = USER AND name = 'DBMS_OUTPUT.PUT_LINE'
- SELECT DISTINCT name from ALL_SOURCE WHERE INSTR (text, 'DBMS_OUTPUT.PUT_LINE') > 0
- SELECT DISTINCT name from USER_SOURCE WHERE INSTR (UPPER (text), 'DBMS_OUTPUT.PUT_LINE') > 0
PL/SQL raises an exception, in which TWO of the following cases:
- When a SELECT statement returns no rows
- When a SELECT statement returns more than one row
- When the datatypes of SELECT clause and INTO clause do not match
- When INTO statement is missing in the SELECT statement
What is the result if two NULL values are compared to each other?
- TRUE
- FALSE
- UNDEFINED
- NULL
Functions for error trapping are contained in which section of a PL/SQL block?
- Header
- Declarative
- Executable
- Exception
What is the smallest possible PL/SQL block?
- Begin null; end;
- Declare x varchar2(100); begin dbms_output.put_line(x); end;
- Begin .. statement1; exception ... end;
- Begin dbms_output.put_line(sysdate); end;;
Maximum no of non clustered index in a table.
- 192
- 255
- 249
- 300
Maximum no of columns in a key.
- 1
- 31
- 16
- 255
maximum number of segments for any database
- 8
- 1
- 31
- 32
The maximum allowable size of the combined index values
- 255
- 600
- 256
- 32
maximum length for comments
- there is no limit
- 16843
- 255
- 1024
maximum of triggers in sybase
- 3
- 12
- 6
- 9