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

Introduction to SQL Questions and Answers

61.

Most companies keep at least two versions of any database they are using.

Answer: A

Correct answer: True

The two are the production database, which the business runs on, and at least one test or development copy where changes are tried out.

The reason is that a schema change or a new query cannot be rehearsed safely on live data: a mistake there costs real transactions and may not be reversible. Larger organisations keep more than two - development, test, staging and production - with a defined path for promoting a change through them, and the test copies are refreshed periodically from production so that the data resembles the real thing.

Please log in or register to report this question.

62.

The rows of the result relation produced by a SELECT statement can be sorted, but only by one column.

Answer: B

Correct answer: False

ORDER BY accepts a list of columns, each with its own direction: ORDER BY dept ASC, salary DESC sorts by department and then, within each department, by descending salary.

The later columns act as tie-breakers, which is what makes multi-column sorting useful rather than merely possible. Expressions and column positions are also permitted, so ORDER BY LENGTH(name) or ORDER BY 2 are valid, though the numeric form is fragile when the SELECT list changes.

Please log in or register to report this question.

63.

SQL provides the AS keyword, which can be used to assign meaningful column names to the results of queries using the SQL built-in functions.

Answer: A

Correct answer: True

AS assigns an alias, and it is particularly useful with aggregates, whose default column names are the expressions themselves - COUNT(*) or worse. SELECT COUNT(*) AS order_count gives the result a name a program or a report can use.

It also aliases tables, as in FROM customer AS c, which is what makes a self-join possible. The keyword is optional in most dialects for both purposes, but writing it makes the intent explicit and avoids a missing comma silently becoming an alias.

Please log in or register to report this question.

64.

Which one of the following sorts rows in SQL?

Answer: C

Correct answer: ORDER BY

ORDER BY sorts the rows of a result, ascending by default and descending with DESC, and may name several columns for tie-breaking.

GROUP BY is the near-miss: it collects rows into groups for aggregation and does not guarantee any particular output order, though some engines happen to return groups sorted. SORT BY and ALIGN BY are not SQL. Note that without ORDER BY a result has no defined order at all - a set has no sequence - so any order observed is incidental.

Please log in or register to report this question.

Answer: A

Correct answer: use FROM to name the source table(s) and list the columns to be shown after SELECT.

Each clause has one job. FROM names the source - a table, several joined tables, a view or a subquery - and the SELECT list names the columns to be returned from it.

In relational terms these are the two basic operations: SELECT performs projection, choosing columns, and WHERE performs selection, choosing rows. USING exists in SQL but for a narrower purpose - naming the shared column in a join, as in JOIN orders USING (customer_id) - and never names the source table.

Please log in or register to report this question.

66.

The basic data type char(n) is a _____ length character string and varchar(n) is _____ length character.

Answer: C

Correct answer: Fixed, variable

char(n) always occupies \( n \) characters: a shorter value is padded with trailing spaces to fill the width. varchar(n) stores only the characters actually supplied, up to a maximum of \( n \).

The trade is space against predictability. char wastes space on short values but has a fixed offset, which can make row access marginally faster; varchar stores just what is needed at the cost of a length prefix. The practical rule is char for genuinely fixed-width codes and varchar for anything that varies.

Please log in or register to report this question.

Answer: A

Correct answer: for ranges.

BETWEEN tests whether a value falls within a range, and the range is inclusive at both ends: WHERE age BETWEEN 18 AND 65 is the same as age >= 18 AND age <= 65.

That inclusivity is the point most often got wrong, particularly with dates, where BETWEEN '2026-01-01' AND '2026-01-31' excludes anything timestamped later on the last day. It filters rows, so it does not limit columns, and it takes exact values rather than patterns, so it is not a wildcard construct.

Please log in or register to report this question.

68.

The SELECT command, with its various clauses, allows users to query the data contained in the tables and ask many different questions or ad hoc queries.

Answer: A

Correct answer: True

This is what distinguishes a relational database from the file-based systems it replaced. SELECT, with its clauses for filtering, grouping, ordering and joining, lets a user pose a question the database designer never anticipated.

That is what "ad hoc" means here: the query is composed when the question arises, not built into the application in advance. Earlier models required navigating predefined access paths, so a new question often meant new code. Declaring what is wanted rather than how to fetch it is the whole point.

Please log in or register to report this question.

Answer: C

Correct answer: DELETE FROM CUSTOMER WHERE .

DELETE FROM removes rows, and the WHERE clause decides which. Omitting the clause is legal and empties the whole table, which is why writing the WHERE first is a habit worth having.

DROP destroys the table itself, structure and all, so it belongs to the data definition language rather than to row manipulation. UPDATE changes values in rows that remain. REMOVE is not SQL. Note that DELETE leaves the empty table in place, ready for new rows.

Please log in or register to report this question.

70.

The HAVING clause acts like a WHERE clause, but it identifies groups that meet a criterion, rather than rows.

Answer: A

Correct answer: True

HAVING is the group-level counterpart of WHERE. It runs after GROUP BY has formed the groups and after the aggregates have been computed, so it can test them: HAVING COUNT(*) > 5 keeps only groups with more than five rows.

WHERE runs earlier, deciding which rows enter the groups, and cannot refer to an aggregate because at that point no group exists. Filtering on a plain column therefore belongs in WHERE, where it reduces the rows to be grouped, not in HAVING.

Please log in or register to report this question.

Loading…

Other Subjects

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