Machine-translated by Google. Questions are authored in English.
Top

Advanced SQL Questions and Answers

21.

ROLLBACK WORK asks SQL to empty the log file.

Answer: A

Correct answer: True

ROLLBACK WORK undoes the transaction by applying the before-images from the log and then discards them, so the log entries for that transaction are emptied. The database returns to the state it held when the transaction began.

Please log in or register to report this question.

22.

What type of join is needed when you wish to include rows that do not have matching values?

Answer: C

Correct answer: Outer join

An outer join keeps the rows that have no match on the other side and fills the missing columns with nulls. Equi-joins and natural joins discard them, so a customer with no orders would simply disappear - which is precisely the case an outer join exists to report.

Please log in or register to report this question.

23.

There should be one condition within the WHERE clause for each pair of tables being joined.

Answer: A

Correct answer: True

Each pair of tables joined needs a condition linking them, so joining n tables requires at least n minus one conditions. Omitting one leaves that pair unconstrained and produces a Cartesian product with the rest, which is why a query that suddenly returns an enormous result usually has a missing join condition.

Please log in or register to report this question.

24.

A function returns one value and has only output parameters.

Answer: B

Correct answer: False

A function returns a single value and takes only input parameters, which is what allows it to be used within an expression like any built-in function. Output parameters belong to procedures, which is one of the two things distinguishing the two kinds of routine.

Please log in or register to report this question.

25.

The UNION clause is used to combine the output from multiple queries together into a single result table.

Answer: A

Correct answer: True

UNION takes the results of two or more queries and stacks them into one table, removing duplicate rows unless UNION ALL is used. The queries must be union compatible - the same number of columns, with corresponding types - since otherwise the rows could not be stacked at all.

Please log in or register to report this question.

26.

The following SQL is which type of join: SELECT CUSTOMER_T. CUSTOMER_ID, ORDER_T. CUSTOMER_ID, NAME, ORDER_ID FROM CUSTOMER_T,ORDER_T ;

Answer: D

Correct answer: Cartesian join

Two tables are named in the FROM clause and no join condition is given, so every row of one is paired with every row of the other. The result has the product of the two row counts, which is almost never wanted - an accidental Cartesian product from a forgotten WHERE clause is the classic runaway query.

Please log in or register to report this question.

Answer: A

Correct answer: A way to establish an IF-THEN-ELSE in SQL.

CASE evaluates conditions in order and yields the value belonging to the first that holds, which is a conditional expression rather than a statement. It can therefore appear anywhere a value is expected - in a select list, in an ORDER BY, or inside an aggregate.

Please log in or register to report this question.

Answer: B

Correlated subquery references a column in the outer query and executes the subquery once for every row in the outer query while Uncorrelated subquery executes the subquery first and passes the value to the outer query.

Please log in or register to report this question.

29.

A transaction is the complete set of closely related update commands that must all be done, or none of them done, for the database to remain valid.

Answer: A

Correct answer: True

This is the definition of atomicity. The set of updates either all take effect or none does, so the database moves from one consistent state to another and is never left part way - the transfer that debits one account and fails to credit the other being the standard illustration.

Please log in or register to report this question.

Answer: A

Correct answer: Involves the use of an inner and outer query.

A subquery is a SELECT nested inside another, the inner supplying a value or a set to the outer. Many subqueries can be rewritten as joins and return identical results, and the choice between them is usually a matter of readability rather than of what is possible.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Advanced SQL Questions and Answers || Advanced SQL MCQ Questions and Answers || Advanced SQL GK Questions and Answers || Advanced SQL GK MCQ Questions || Advanced SQL Multiple Choice Questions and Answers || Advanced SQL GK || GK on Advanced SQL || Database Questions and Answers || Database MCQ Questions and Answers || Database GK Questions and Answers || GK on Database