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

Introduction to SQL Questions and Answers

51.

ORDER BY can be combined with the SELECT statements.

Answer: A

Correct answer: True

ORDER BY is a clause of the SELECT statement and comes last, after WHERE, GROUP BY and HAVING - sorting is the final operation applied to what those have produced.

It is worth combining deliberately rather than by habit: without it the result has no defined order at all, because a relation is a set. Any order observed without it is incidental to how the engine happened to read the data, and it can change when the table grows or an index is added.

Please log in or register to report this question.

52.

Data manipulation language (DML) commands are used to define a database, including creating, altering, and dropping tables and establishing constraints.

Answer: B

Correct answer: False

The sentence describes DDL, the Data Definition Language, not DML. Creating, altering and dropping tables and establishing constraints are all structural operations.

DML works with the data inside those structures: SELECT, INSERT, UPDATE and DELETE. The distinction has a practical edge beyond terminology - in most engines DDL statements commit implicitly and cannot be rolled back, while DML statements participate in a transaction.

Please log in or register to report this question.

Answer: B

Correct answer: An exact match is not possible in a SELECT statement.

Wildcards exist for the case where the exact value is unknown or where a pattern rather than a value is wanted - every surname beginning with "Mc", every product code with a particular third character.

Where the value is known exactly, = is both simpler and faster, since an equality test can use an index while a pattern beginning with a wildcard generally cannot. Wildcards belong to LIKE in a WHERE clause, so they have no place in a CREATE statement, which defines structure rather than selecting data.

Please log in or register to report this question.

Answer: D

Correct answer: All of the above.

SQL was designed as a complete language for relational databases, so it covers all three.

The data definition half defines structures - CREATE, ALTER, DROP. The manipulation half queries and changes data - SELECT, INSERT, UPDATE, DELETE. Defining the data structures is what the first half achieves. That combination is what made SQL displace the separate languages the earlier database models required, and it is why one standard covers both syntax and semantics.

Please log in or register to report this question.

55.

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.

56.

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.

57.

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.

59.

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.

60.

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.

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