CPTR 322 Final Exam Review

CPTR 322 Final Exam Review

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

A view that is not updateable is called a ________ view.

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

1

All-time users

1

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (71)

Section 1

(50 cards)

A view that is not updateable is called a ________ view.

Front

read-only

Back

To replace an existing view with a new one, you use the _______ statement.

Front

CREATE OR REPLACE VIEW

Back

In the view that follows, which field can't be updated CREATE VIEW example_2 AS SELECT invoice_number, invoice_date, invoice_total, payment_total, invoice_total - payment_total - credit_total AS balance_due, SYSDATE() - invoice_date AS days_old FROM invoices A. invoice_total B. balance_due C. invoice_date D. all of the above

Front

B. balance_due

Back

Code a SQL statement that displays the value of a variable named message_var.

Front

SELECT(message_var) AS message_var;

Back

To turn the event scheduler on or off, you can use the _______ statement.

Front

SET

Back

The ______ statement raises an error.

Front

SIGNAL

Back

The WITH CHECK OPTION clause of the CREATE VIEW statement a. prevents users from using the view without the appropriate authorization b. prevents an update from being performed through the view if it causes a row to be excluded from the view c. prevents rows from being deleted through the view d. prevents rows from being inserted through the view

Front

B. prevents an update from being performed through the view if it causes a row to be excluded from the view

Back

A/An _______ stores a value that can change as a procedure executes.

Front

variable

Back

When working with dynamic SQL, you use a stored routine to build a string variable that contains a SQL statement. Then, you use the ________, EXECUTE, and DEALLOCATE statements to execute the statement contained in the string.

Front

PREPARE

Back

To create a row-level trigger, you must code the ______ clause.

Front

FOR EACH ROW

Back

If you want MySQL to exit the current block of code as soon as it encounters an error, you use a/an _____ handler.

Front

EXIT

Back

With MySQL, you can only create ______ functions, which return a single value.

Front

scalar

Back

MySQL automatically avoids some concurrency problems by using _______.

Front

locks, locking

Back

Assume that this is the start of the code for a store procedure: CREATE OR REPLACE PROCEDURE update_credits ( in_param VARCHAR(50), cr_param DECIMAL(9,2) ) AS Then, code a CALL statement that calls the stored procedure and passes the values 47B and 200 to it.

Front

CALL update_credits('47B', 200);

Back

You can use the DECLARE...HANDLER statement to declare a handler for errors that may occur. In MySQL this is referred to as a/an ______ handler.

Front

condition

Back

To work with the data in a result set one row at a time, you would use a/an _______.

Front

cursor

Back

You usually don't insert rows into a table through view because A. due to table constraints, using a view to insert rows often results in errors B. the view would have to include all of the required columns for the base table that require a value C. if the view names more than one base table, the INSERT statement can insert data into only one of those tables D. all of the above

Front

D. all of the above

Back

A table that's used to create a view is called a/an ____ table.

Front

base, underlying

Back

Each of the following is a benefit provided by using views except for one. Which on is it? a. Views can be used to update multiple tables with a single statement. b. You can use views to limit the exposure of the tables in your database to certain rows or applications. c. Views can be used to hide the complexity of retrieval operations. d. You can code views that join tables.

Front

A. Views can be used to update multiple tables with a single statement.

Back

To set a default value for a parameter, you can use a/an ______ statement to check if the parameter contains a null value.

Front

IF

Back

MySQL only supports _______ triggers.

Front

row_level

Back

To insert rows into an audit table, you typically use a/an _______ trigger.

Front

AFTER

Back

When you use _____ with transactions, you can rollback a transaction to the beginning of a transaction.

Front

save points

Back

A trigger is anamed block of code that executes, or _________, in response to an INSERT, UPDATE, or DELETE statement.

Front

fires, runs

Back

A view is a/an ______ statement that's stored in the database as a database object.

Front

SELECT

Back

By default, MySQL uses ____ mode for INSERT, UPDATE, or DELETE statements.

Front

autocommit

Back

One of the best reasons for using views is that they can limit the exposure of the tables in your database to external _______ and applications.

Front

users

Back

The statement CREATE VIEW example_1 AS SELECT vendor_name, SUM(invoice_total) AS sum_of_invoices FROM vendors JOIN invoices ON vendors.vendor_id = invoices.vendor_id GROUP BY vendor_name ORDER BY vendor_name A. will fail because the GROUP BY clause isn't allowed B. will fail because SUM function isn't allowed C. will fail because the ORDER BY clause isn't allowed D. will succeed

Front

D. will succeed

Back

An event can be a one-time event that occurs only once or a ______ event that occurs regularly at a specified interval.

Front

recurring

Back

To create a procedure, you use the CREATE PROCEDURE statement, but to execute a procedure you use the ______ statement.

Front

CALL

Back

You can use a/an _______ to pass one or more values from the calling program to the stored procedure.

Front

parameter, input parameter

Back

The _______ statement turns off autocommit mode until statements in the transaction are committed or rolled back.

Front

START TRANSACTION

Back

Transactions are not supported by the _____ database engine.

Front

MyISAM

Back

A ________ occurs when neither of two transactions can be committed because they each have a lock on a resource needed by the other.

Front

deadlock

Back

To repeatedly execute a SQL statement, you can code a simple loop, a WHILE loop, or a/an _____ loop.

Front

REPEAT

Back

If you want to allow MySQL to attempt to execute statements in a block of code even after it encounters an error, you should use a/an ______ handler.

Front

CONTINUE

Back

When you work with output parameters or input/output parameters, the calling program typically passes a/an _______ to the parameter list.

Front

user variable

Back

If you don't include a/an _______ clause when you create a view, a change you make through the view can clause the modified rows to no longer be included in the view.

Front

WITH CHECK OPTION

Back

An event executes according to the event _______.

Front

scheduler

Back

When you use a BEFORE trigger to work with an UPDATE statement, you can use the keyword and a column name to refer to a value in the row before it is updated.

Front

OLD

Back

Triggers can be used to enforce rules for data consistency that can't be enforced by _________.

Front

constraints

Back

Code a SQL statement that declares a variable named message_var with a VARCHAR data type that can store a maximum of 140 characters. Then, code a second statement that assigns the value "Test" to that variable.

Front

DECLARE message_var VARCHAR(140); SET message_var = 'Test';

Back

A stored program that automatically executes in response to an INSERT, UPDATE, or DELETE statement is called a/an _________.

Front

trigger

Back

Which of the following can be used with an updateable view? a. a DISTINCT clause b. a join c. an aggregate function d. the UNION operator

Front

B. a join

Back

When you raise an error in a stored procedure, you must specify a/an ______ code.

Front

SQLSTATE

Back

A view that is based on another views, rather than a table is called a ________ view.

Front

nested

Back

A/An __________ statement is used to execute one or more statements based on a value that's returned by a Boolean expression.

Front

IF

Back

Assume that this is the start of the code for creating a stored function: CREATE OR REPLACE FUNCTION get_days_overdue ( invoice_date_param DATE, invoice_terms_param INT ) RETURN INT AS Code the column specifications that you would use in a SELECT statement to pass the invoice_date and invoice_terms columns to the function and use days_old as the column name.

Front

get_days_overdue(invoice_date, invoice_terms) AS days_old

Back

________ parameters store values that are passed back to the calling program.

Front

Output

Back

If you declare multiple condition handlers when coding a stored program, you should code the _____ specific error handler last.

Front

least

Back

Section 2

(21 cards)

You can use the _______ statement to go to the end of a loop. A. END B. LEAVE C. ITERATE. D. WHILE

Front

B. LEAVE

Back

Each of the following statements about triggers is true except for one. Which one is it? A. A trigger can work for the new or old values in a row B. In MySQL, you must specify a FOR EACH ROW clause C. A trigger responds to the event scheduler D. A trigger responds to an INSERT, UPDATE, or DELETE statement

Front

C. A trigger responds to the event scheduler

Back

Using procedural code to build and execute a SQL statement that depends on parameters that aren't known until runtime is known as A. a user-defined function B. a user variable C. dynamic SQL D. all of the above

Front

C. dynamic SQL

Back

Checking parameters before they're used to make sure they're valid is referred to as: A. raising an error B. data validation C. throwing an exception D. all of the above

Front

B. data validation

Back

When you use save points, you can roll back a transaction A. to the beginning of the transaction B. to a particular save point C. all of the above

Front

C. all of the above

Back

Which built-in condition occurs when any error condition other than the NOT FOUND condition occurs or when any warning messages occur. A. SQLEXCEPTION B. SQLWARNING C. SQLINFO D. all of the above

Front

B. SQLWARNING

Back

Which type of loop will be executed at least once? A. simple loop B. REPEAT loop C. WHILE loop D. all of the above

Front

B. REPEAT loop

Back

When using a cursor to get column values from the row and store them in a series of variables, you use the ________ statement. A. UPDATE B. OPEN C. FETCH D. WHILE

Front

C. FETCH

Back

By default, parameters are defined as ________ parameters. A. input B. output C. input/output D. all of the above

Front

A. input

Back

A lost update occurs when A. you perform an update on a set of rows when another transaction is performing an insert that affects one or more rows in that same set of rows B. a transaction selects data that isn't committed by another transaction C. two transactions select the same row and then update the row based on the valued originally selected D. two SELECT statements that select the same data get different values because another transaction has updated the data in the time between the two statements

Front

C. two transactions select the same row and then update the row based on the valued originally selected

Back

When you use a stored procedure to insert a row into a table, the procedure must provide input parameters for A. every column B. every column except for columns that have default values C. every column except for columns that have default values or can accept null values D. every column except for columns that have default values, can accept null values, or are defined as auto increment columns

Front

D. every column except for columns that have default values, can accept null values, or are defined as auto increment columns

Back

MySQL Workbench can help get you started writing scripts that create stored procedures and functions. When you select the Create Stored Procedures or the Create Stored Function node, MySQL Workbench automatically generates some basic code for the routine, including: A. a DELIMITER statement B. BEGIN and END keywords C. a CREATE PROCEDURE statement D. all of the above

Front

D. all of the above

Back

Which of the following is the beginning of a trigger named customers_after_insert that's executed after an INSERT statement on the table named customers? A. CREATE TRIGGER customer_after_invoices AFTER INSERT customers B. CREATE TRIGGER customers_after_invoices AFTER INSERT ON customers C. CREATE TRIGGER customers AFTER INSERT customers_after_invoices D. CREATE TRIGGER customers INSERT AFTER ON customers

Front

B. CREATE TRIGGER customers_after_invoices AFTER INSERT ON customers

Back

Each of the following is a valid reason to use a transaction except for one. Which one is it? A. When you code two or more INSERT, UPDATE, or DELETE statements that affect related data. B. The failure of one statement in a set of INSERT, UPDATE, or DELETE statements will violate data integrity. C. When you move rows from one table to another table by using INSERT and DELETE statements. D. The results of a SELECT query will be used as a subquery

Front

D. The results of a SELECT query will be used as a subquery

Back

You would use a trigger for all but one of the following. Which one is it? A. to enforce data consistency B. to create an audit table C. to store information about actions that occur in the database D. to add rows to an audit table

Front

B. to create an audit table

Back

Each of the following techniques can help to prevent deadlocks except for one. Which one is it? A. Don't leave transactions open any longer than necessary B. Use the highest isolation level possible C. Schedule transactions that modify a large number of rows so they run when no other transactions will be running D. If you code two transactions that update the same resources, code the updates in the same order in each transaction

Front

B. Use the highest isolation level possible

Back

At the highest isolation level, MySQL can prevent A. dirty reads B. lost updates C. non-repeatable reads D. all of the above

Front

D. all of the above

Back

You can code views that: A. join tables B. summarize data C. use subqueries and functions D. all of the above

Front

D. all of the above

Back

By default, MySQL prevents all but one of the following types of concurrency problems. A. lost updates B. dirty reads C. non-repeatable reads D. phantom reads

Front

D. phantom reads

Back

To code an event that executes every month, you would use the _______ keyboard. A. SET B. GLOBAL C. AT D. EVERY

Front

D. EVERY

Back

A user variable is: A. available from statements coded both inside and outside of stored programs B. only available to the current user and cannot be seen or accessed by other users C. able to store various data types including string, numeric, and date/time types D. all of the above

Front

D. all of the above

Back