Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Section 3
1. Does PL/SQL allow you to have a variable with the same name as a database column?
Mark for Review
(1) Points
Yes (*)
No
Correct
2. When used in a PL/SQL block, which SQL statement must return exactly one row?
Mark for Review
(1) Points
INSERT
DELETE
SELECT (*)
MERGE
UPDATE
Correct
DECLARE
v_result employees.salary%TYPE;
BEGIN
(1) Points
SELECT SUM(salary)
INTO v_result
FROM employees; (*)
SELECT salary
INTO v_result
FROM employees
WHERE last_name ='Smith';
SELECT salary
INTO v_result
FROM employees
WHERE department_id = 80;
SELECT salary
INTO v_result
FROM employees;
Incorrect. Refer to Section 3 Lesson 2.
4. Which one of these SQL statements can be directly included in a PL/SQL executable
block?
Mark for Review
(1) Points
DROP TABLE locations;
CREATE TABLE new_emps (last_name VARCHAR2(10), first_name VARCHAR2(10));
5. Which SQL statements can be used directly in a PL/SQL block? (Choose two.)
Mark for Review
(1) Points
GRANT EXECUTE ON ...
ALTER TABLE employees ...
SELECT * INTO ... (*)
REVOKE SELECT ON ...
UPDATE employees
SET... (*)
Incorrect. Refer to Section 3 Lesson 2.
BEGIN
INSERT INTO countries (country_id, country_name)
VALUES ('XA', 'Xanadu');
INSERT INTO countries (country_id, country_name)
VALUES ('NV', 'Neverland');
UPDATE countries
SET country_name='Deutchland'
WHERE country_id='DE';
UPDATE countries
SET region_id=1
WHERE country_name LIKE '%stan';
END;
(1) Points
Two; both the INSERTs are one transaction and both the UPDATEs are a second transaction.
One (*)
Four; each DML is a separate transaction
It depends on how many rows are updated - there will be a separate transaction for each row.
Correct
(1) Points
In any section of the block: Declaration, Executable, or Exception.
In the Executable and/or the Exception sections. (*)
Only the Executable section.
Nowhere; the COMMIT statement must be outside the block.
Correct
8. What would be the result of the following statement: DELETE FROM employees;
Mark for Review
(1) Points
Nothing, no data will be changed.
The row with EMPOYEE_ID=100 will be deleted.
The statement will fail because it contains a syntax error.
All rows in the employees table will be deleted. (*)
Correct
9. Is it possible to insert more than one row at a time using an INSERT statement with a
VALUES clause?
Mark for Review
(1) Points
No, you can only create one row at a time when using the VALUES clause. (*)
No, there is no such thing as INSERT ... VALUES.
Yes, you can list as many rows as you want, just remember to separate the rows with
commas.
Correct
(1) Points
Nothing is wrong, the statement will execute correctly.
The UPDATE clause must include the target table name: UPDATE emps SET ....
The SET clause is trying to update the source table from the target table. (*)
The INSERT clause must include a column list as well as a list of column values.
Correct
11. When explicitly inserting a row into a table, the VALUES clause must include a value for
every column of the table. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
12. Which of the following will delete all employees who work in the Sales department?
Mark for Review
(1) Points
DELETE FROM employees
WHERE department_id =
SELECT department_id
FROM departments
WHERE department_name = 'Sales';
DELETE FROM employees e, departments d
WHERE e.department_id = d.department_id
AND department_name = 'Sales';
DELETE (SELECT department_id
FROM departments
WHERE department_name = 'Sales')
FROM employees;
DELETE FROM employees
WHERE department_id =
(SELECT department_id
FROM departments
WHERE department_name = 'Sales'); (*)
Correct
(1) Points
COMMIT and ROLLBACK statements only.
DML statements and SELECT statements which return a single row. (*)
SELECT statements only.
DML statements only.
Correct
14. Employee_id 999 does not exist. What will happen when the following code is executed?
DECLARE
employee_id employees.employee_id%TYPE := 999;
BEGIN
UPDATE employees
SET salary = salary * 1.1
WHERE employee_id = employee_id;
END;
(1) Points
Every employee row is updated. (*)
An exception is raised because you cannot give a variable the same name as a table column.
An exception is raised because the UPDATE statement did not modify any rows.
No rows are updated but the block completes successfully.
Correct
UPDATE wf_countries
SET population = population * 1.1
WHERE country_id = 229;
(1) Points
An explicit cursor which must be declared and named by the PL/SQL programmer.
An implicit cursor named "SQL". (*)
An implicit cursor named "WF_COUNTRIES".
An explicit cursor named "SQL".
Correct