Midterms - Database Flashcards
The ______ clause is used in DML statement to specify variable(s) that will hold the value(s) that SQL returns from the SELECT clause.
INTO
The use of INTO clause in PL/SQL select statement is to specify the name of ________.
VARIABLE
The INTO clause occurs between the SELECT and _______ clauses.
FROM
The DML statement: INSERT, DELETE, ________ make changes to the database.
UPDATE
Which SQL statements cannot be used directly in PL/SQL?
Group of answer choices
DDL, DCL
DML
TCL
DML, TCL
DDL, DCL
What could be the possible error of the given code below?
DECLARE
v_sal_increase employees.salary%TYPE := 800;
BEGIN
UPDATE copy_emp
SET salary = salary + v_sal_increase
WHERE job_id = ‘ST_CLERK’;
END;
Group of answer choices
WHERE section
Variable declaration
No error
SET section
No error
What could be the possible error of the given code below?
DECLARE
v_sal_increase employees.salary%TYPE = 800;
BEGIN
UPDATE copy_emp
SET salary = salary + v_sal_increase
WHERE job_id = ‘ST_CLERK’;
END;
Group of answer choices
SET section
No error
WHERE section
Variable declaration
Variable declaration
The memory area allocated by Oracle server to store the SQL statement and the data that it uses in known as:
Cursor
The use of CASE statement to test conditions such as <, >, >=, <= is know as case expression.
False
Applying the logical operator NOT to a null yields FALSE.
False
The type of loop where the statement inside the loop must execute at least once.
BASIC
In BASIC and WHILE loop, the iteration will terminate when the counter is > than the upper bound.
Group of answer choices
True
False
FALSE
In BASIC and WHILE loop, initialization of counter variable is necessary.
TRUE
The ______ is a Boolean attribute that evaluates to TRUE if the most recent SQL statement did not return even one row.
SQL%NOTFOUND
The DDL and _______ SQL statements cannot be used directly in PL/SQL.
DCL
The _______cursor are automatically defined by Oracle.
IMPLICIT
What could be the possible error of the given code below?
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary
FROM employees;
DBMS_OUTPUT.PUT_LINE(‘ Salary is : ‘ || v_salary);
END;
Query returns more than 1 row
The _______ statement selects rows from one table to update and/or insert into another table.
Group of answer choices
DML
COMBINE
MERGE
SELECT, INSERT, UPDATE
MERGE
What is missing in the given code below?
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO ________
FROM employees where employee_id = 100;
DBMS_OUTPUT.PUT_LINE(‘ Salary is : ‘ || v_salary);
END;
V_SALARY
What could be the possible error of the given code below?
DECLARE
v_sum_sal NUMBER(10,2);
v_deptno NUMBER NOT NULL := 60;
BEGIN
SELECT SUM(salary)
INTO v_sum_sal FROM employees WHERE department_id = v_deptno;
DBMS_OUTPUT.PUT_LINE(‘Dep #60 Salary Total: ‘ || v_sum_sal);
END;
No error
Consider the given code fragment below. The condition will return a false value.
A:=null; B:=null;
If A = B then . . . . .
TRUE
The BASIC LOOP control structures are statements that enable you to execute statements in a PL/SQL block repeatedly.
Group of answer choices
True
False
TRUE
In for loop, counter must be explicitly declared.
Group of answer choices
True
False
False
In BASIC and WHILE loop, the iteration will terminate when the counter is < than the upper bound.
False
The INTO clause occurs between the _______ and FROM clauses.
SELECT
The memory area allocated by Oracle server to store the SQL statement and the data that it uses in known as __________.
IMPLICIT CURSOR
Which DML statement make changes to the database?
Group of answer choices
INSERT
DELETE
All the options
UPDATE
All the options
The code below must print the number of rows updated, what is the missing part of the code?
Declare
v_cal_increase employees.salary%type := 800;
begin
update copy_emp
set salary = salary + v_sal_increase
where job_id = ‘ST_CLERK’;
dbms_output.put_line(_____________ || ‘ rows updated.’);
end;
SQL%ROWCOUNT
The code below must print the number of rows updated. Which part of the code must be changed to satisfy the output?
Declare
v_sal_increase employees.salary%type := 800;
begin
update copy_emp
set salary = salary + v_sal_increase
where job_id = ‘ST_CLERK’;
dbms_output.put_line(SQL%FOUND || ‘ rows updated.’);
end;
SQL%FOUND
Consider the given code fragment below. The condition will return a true value.
A:=null; B:=null;
If A = B then . . . . .
False
Applying the logical operator NOT to a null yields NULL.
Group of answer choices
True
False
True
In for loop, counter variable is declared _______.
IMPLICITLY
Without the EXIT statement, the loop would never end (an infinite loop).
True
All counter variables must be declared at the declaration section.
Group of answer choices
True
False
FALSE
An EXIT statement is used in order to come out of from the outer loop within an inner loop.
Group of answer choices
True
False
False
The _________ SQL Rule: queries must return only one row.
EMBEDDED
The _____ is an integer value that represents the number of rows affected by the most recent SQL statement.
SQL%ROWCOUNT
The _____ statement selects rows from one table to update and/or insert into another table.
MERGE
The ______ are automatically declared variables that allow you to evaluate what happened when a cursor was last used.
Group of answer choices
Explicit attributes
Cursor attributes
Attributes
Implicit attributes
Cursor attributes
What could be the possible error of the given code below?
DECLARE
v_salary employees.salary%TYPE;
BEGIN
SELECT salary INTO v_salary
FROM employees where employee_id = 100;
DBMS_OUTPUT.PUT_LINE(‘ Salary is : ‘ || v_salary);
END;
Group of answer choices
VARIABLE ERROR
Query returns more than 1 row
TABLE ERROR
NO ERROR
NO ERROR
A counter variable is an expression that returns true, false, or null.
Group of answer choices
True
False
False
What is missing in the given WHILE loop syntax? ________
WHILE condition
statement1;
statement2;
. . .
END ;
LOOP
A loop structure must have an exit clause.
Group of answer choices
True
False
True
What could be the possible error of the given code below?
DECLARE
v_sum_sal NUMBER(10,2);
v_deptno NUMBER NOT NULL := 60;
BEGIN
SELECT SUM(salary) FROM employees WHERE department_id = v_deptno;
DBMS_OUTPUT.PUT_LINE(‘Dep #60 Salary Total: ‘ || v_sum_sal);
END;
Group of answer choices
Group function error
Query returns more than 1 row
Variable error
Missing INTO clause
Missing INTO clause
Is there something missing in the given code?
DECLARE
v_myage NUMBER := 31;
BEGIN
IF v_myage < 11
DBMS_OUTPUT.PUT_LINE(‘I am a child’);
END IF;
END;
Group of answer choices
True
False
True
A ________ is used in order to come out of from the outer loop within an inner loop.
LOOP LABELS
The lower and upper bound of a for loop must be a numeric literals.
Group of answer choices
True
False
False
The _________ cursors are defined by the PL/SQL programmer.
EXPLICIT
What is the output of the given code below?
DECLARE
v_deptno copy_emp.department_id%TYPE := 50;
BEGIN
DELETE FROM copy_emp
WHERE department_id = v_deptno;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT || ‘ rows deleted.’);
END;
Print the number of rows deleted
Control structures are used to change the logical flow of statements within the PL/SQL block.
Group of answer choices
True
False
True
Use the ______ loop when the statement inside the loop must execute at least once.
BASIC
The use of INTO clause in PL/SQL select statement is to specify the name of: ____________.
Group of answer choices
VARIABLE
CURSOR
TABLE
VIEW
VARIABLE
The code below must print the number of rows deleted. What is missing in the given code to satisfy the output?
DECLARE
v_deptno copy_emp.department_id%TYPE := 50;
BEGIN
DELETE FROM copy_emp
WHERE _____________ = v_deptno;
DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT || ‘ rows deleted.’);
END;
Group of answer choices
DEPARTMENT_ID
DEPARTMENTS
JOBS
JOB_ID
DEPARTMENT_ID
Use a DO..WHILE loop when the statement inside the loop must execute at least once.
Group of answer choices
True
False
False
Start with the _____ keyword to define a user-defined record structure.
TYPE
Given:
DECLARE v_emp_record \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_;
What is missing in the declaration section if we want to declare v_emp_record as type record of EMPLOYEES table? __________
EMPLOYEES%ROWTYPE
The OPEN will populate the cursor’s active set with the result of the SELECT statement in the cursor’s definition?
True
False
True
The FETCH statement positions the cursor pointer at the first row.
Group of answer choices
True
False
False
What is missing in the given exception syntax? ____
EXCEPTION
WHEN exception1 [OR exception2 . . .] statement1; statement2;
THEN
Always add ________ whenever there is a possibility of an error occurring.
EXCEPTION HANDLERS
Handle named exceptions whenever possible, instead of using ______ in exception handlers.
OTHERS
Error in PL/SQL is known as ____________.
EXCEPTION
Each ________ is consists of a WHEN clause, which specifies an exception name.
HANDLER