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

Introduction to SQL Questions and Answers

31.

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.

32.

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.

33.

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.

34.

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.

35.

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.

36.

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.

38.

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.

40.

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.

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