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

Introduction to SQL Questions and Answers

11.

DISTINCT and its counterpart, ALL, can be used more than once in a SELECT statement.

Answer: B

Correct answer: False

DISTINCT and ALL qualify the SELECT list as a whole and may appear only once, immediately after SELECT. They are mutually exclusive, and ALL - keep duplicates - is the default.

What can appear more than once is DISTINCT inside aggregate functions, as in COUNT(DISTINCT city) alongside SUM(DISTINCT amount). That is a different construct with a different scope: it de-duplicates the values fed to one function rather than the rows of the result.

Please log in or register to report this question.

12.

Which of the following are the five built-in functions provided by SQL?

Answer: A

Correct answer: COUNT, SUM, AVG, MAX, MIN

These five are the standard aggregate functions, each reducing a set of rows to a single value: how many, the total, the mean, the largest and the smallest.

They are usually paired with GROUP BY, which computes one such value per group, and with HAVING, which filters on the result. Two points of behaviour are worth remembering: they ignore nulls, except COUNT(*) which counts rows regardless; and MULT, DIV and NAME in the distractors are not SQL functions at all.

Please log in or register to report this question.

13.

The condition in a WHERE clause can refer to only one value.

Answer: B

Correct answer: False

A WHERE condition can refer to as many values as needed. IN takes a list, BETWEEN takes two bounds, and AND and OR combine any number of conditions across any number of columns.

A condition may also refer to values it does not name, through a subquery: WHERE id IN (SELECT id FROM other) tests against a whole set computed at run time. The single-value comparison is merely the simplest case, not the limit of the clause.

Please log in or register to report this question.

14.

You can add a row using SQL in a database with which of the following?

Answer: C

Correct answer: INSERT

INSERT is the SQL statement that adds rows to a table, in the form INSERT INTO table (col1, col2) VALUES (v1, v2), or with a SELECT in place of VALUES to add many rows from a query.

The distractors trade on the difference between data and structure. CREATE belongs to the data definition language and makes the table itself, not a row in it; ADD appears only as part of ALTER TABLE ... ADD COLUMN, which again changes structure; and MAKE is not SQL at all.

Please log in or register to report this question.

15.

To remove a relation from an SQL database, we use the ______ command.

Answer: D

Correct answer: Drop table

DROP TABLE removes the relation entirely - its rows, its definition, its indexes and its constraints - leaving no object of that name.

DELETE is the near-miss and the distinction is important: it removes rows but keeps the table, so an empty relation remains ready for new data. DROP is a DDL statement and DELETE a DML one. Purge and Remove are not standard SQL for this purpose.

Please log in or register to report this question.

Answer: D

Correct answer: question mark (?); asterisk (*)

Microsoft Access departs from the SQL standard here. It uses * for any sequence of characters and ? for exactly one - the same characters MS-DOS used for file matching.

Standard SQL uses % and _ for those two roles. The difference is a practical trap: a query written in Access and moved to another engine does not fail with an error but simply returns nothing, because * is then matched as a literal asterisk. Access in ANSI-92 mode accepts the standard characters instead.

Please log in or register to report this question.

17.

The keyword BETWEEN can be used in a WHERE clause to refer to a range of values.

Answer: A

Correct answer: True

BETWEEN tests membership of a range and is inclusive at both ends: WHERE age BETWEEN 18 AND 65 is equivalent to age >= 18 AND age <= 65.

The inclusivity is the detail most often overlooked, particularly with timestamps, where BETWEEN '2026-01-01' AND '2026-01-31' excludes anything recorded later on the final day. The lower bound must be written first; giving them in the wrong order returns no rows rather than an error.

Please log in or register to report this question.

18.

SQL is a data sublanguage.

Answer: A

Correct answer: True

SQL is called a data sublanguage because it handles only the data part of an application. It has no loops, no branching, no input or output beyond the result set, and no way to build an interface.

Those come from a host language - C, Java, Python - in which SQL statements are embedded. It is also declarative: a query states what is wanted and leaves the optimiser to decide how to obtain it. Procedural dialects such as PL/SQL add control flow, but they are extensions built on SQL rather than SQL itself.

Please log in or register to report this question.

19.

A dynamic view is one whose contents materialize when referenced.

Answer: A

Correct answer: True

A dynamic view stores only its defining query. Its contents are computed each time it is referenced, so it always reflects the current state of the underlying tables - which is what "materialize when referenced" describes.

The contrast is with a materialized view, which stores the result physically and must be refreshed to stay current. The trade is the familiar one: the dynamic view is always accurate but pays the query cost on every access, while the materialized view is fast to read and may be stale.

Please log in or register to report this question.

20.

A SELECT statement within another SELECT statement and enclosed in square brackets ([...]) is called a subquery.

Answer: B

Correct answer: False

A subquery is enclosed in ordinary parentheses, not square brackets: WHERE id IN (SELECT id FROM other).

The rest of the sentence is right - a subquery is indeed a SELECT nested inside another statement - so the single wrong detail is the delimiter. Square brackets do appear in SQL Server and Access, but to quote identifiers containing spaces or reserved words, as in [Order Details], which is an unrelated use.

Please log in or register to report this question.

Loading…
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