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

Introduction to SQL Questions and Answers

51.

Delete from r; r - relation This command performs which of the following action ?

Answer: B

Correct answer: Clear relation entries

DELETE FROM r with no WHERE clause removes every tuple in the relation, leaving the relation itself in place - defined, empty, and ready for new rows.

That is the precise sense in which the entries are cleared rather than the relation removed: DROP TABLE r would be needed for the latter. Nor are fields affected, since DELETE works on whole rows and never on the column structure. TRUNCATE TABLE achieves the same emptying more quickly, without logging each row.

Please log in or register to report this question.

52.

SQL provides five built-in functions: COUNT, SUM, AVG, MAX, MIN.

Answer: A

Correct answer: True

COUNT, SUM, AVG, MAX and MIN are the five aggregate functions defined by the standard, each reducing a set of rows to a single value.

They are typically used with GROUP BY, which computes one value per group, and filtered with HAVING. All five ignore nulls, with the exception of COUNT(*), which counts rows whatever they contain. Individual products add many more - standard deviation, string aggregation, statistical functions - but those five are the standard set.

Please log in or register to report this question.

53.

The ADD command is used to enter one row of data or to add multiple rows as a result of a query.

Answer: B

Correct answer: False

There is no ADD statement in SQL. The statement that enters rows is INSERT - a single row with VALUES, or many at once with a SELECT supplying them, which is exactly the behaviour the sentence describes.

ADD appears only as a keyword within ALTER TABLE ... ADD COLUMN, which changes the table's structure rather than its contents. The sentence is a correct description of INSERT attached to the wrong keyword.

Please log in or register to report this question.

Answer: A

Correct answer: A virtual table that can be accessed via SQL commands

A view is a stored query that behaves like a table. It has a name, columns and rows, and can be queried with SELECT exactly as a table can - but it stores no data of its own, deriving its contents from the underlying tables each time it is referenced.

That is what "virtual" means here, and it is the difference from a base table, which does hold data. Views serve two purposes in practice: they hide complexity, presenting a join as a single object, and they restrict access, exposing only chosen rows and columns.

Please log in or register to report this question.

55.

Which one of the following is used to define the structure of the relation ,deleting relations and relating schemas ?

Answer: B

Correct answer: DDL(Data Definition Langauge)

Defining a relation's structure, deleting relations and relating schemas are all structural operations, and they belong to the Data Definition Language - CREATE, ALTER and DROP.

DML works on the data those structures hold. A query is one DML statement rather than a language, and a relational schema is the description DDL produces, not the means of producing it. A practical consequence of the split: in most engines DDL commits implicitly and cannot be rolled back.

Please log in or register to report this question.

56.

COUNT(field_name) tallies only those rows that contain a value; it ignores all null values.

Answer: A

Correct answer: True

COUNT(field_name) counts rows in which that field is not null, so nulls reduce the count.

COUNT(*) behaves differently, counting rows regardless of their contents, and the gap between the two is a quick way to find how many nulls a column holds. The same null-skipping applies to SUM, AVG, MIN and MAX, which matters most for AVG: it divides by the number of non-null values, not by the number of rows.

Please log in or register to report this question.

57.

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.

58.

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.

59.

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.

60.

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.

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