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

Introduction to SQL Questions and Answers

11.

Which of the following commands can be used SQL to delete all the records in the table work ?

Exam Year(s)

MH SET - 2024, SET Exam - 2024,

Answer: A

The command is Delete from work.

A DELETE statement without a WHERE clause removes every row from the table, while leaving the table and its structure in place.

Adding where Id = 'Null' deletes only rows whose Id is the string 'Null'. DROP TABLE removes the table itself, not just its records, and REMOVE TABLE is not an SQL command.

Please log in or register to report this question.

Answer: C

The equivalent query uses salary \(\gt\)= 70000 and salary \(\lt\)= 130000.

SQL's BETWEEN is inclusive: salary BETWEEN 70000 and 130000 is true for 70000 and for 130000 as well as for every value between them. So the rewrite needs greater-than-or-equal and less-than-or-equal.

Option A uses strict inequalities and drops the two end values. Option B asks for a salary equal to both numbers at once, which no row satisfies, and option D asks for a salary below 70000 and above 130000 together, which is also impossible.

Please log in or register to report this question.

13.

Which of the following is valid SQL for an Index?

Answer: A

Correct answer: CREATE INDEX ID;

CREATE INDEX is the statement that builds an index, following the same CREATE pattern as tables and views - in full, CREATE INDEX name ON table (column).

An index is a separate structure that lets the engine find rows by a column's value without scanning the whole table, at the cost of space and of slower writes, since every insert and update must maintain it. The counterpart is DROP INDEX. CHANGE, ADD and REMOVE are not SQL statements in their own right.

Please log in or register to report this question.

Answer: C

Correct answer: has a distinct form that cannot be duplicated by a join.

Many subqueries can be rewritten as joins, but not all. A correlated EXISTS or NOT EXISTS, and a comparison against an aggregate of a related set - WHERE salary > (SELECT AVG(salary) FROM emp) - have no direct join equivalent.

The reason is that a join combines rows while a subquery can compute a value or test existence without producing rows. Subqueries are also not limited to two tables, and their outer query can certainly be sorted with ORDER BY.

Please log in or register to report this question.

15.

A subquery in an SQL SELECT statement is enclosed in:

Answer: C

Correct answer: parenthesis -- (...) .

A subquery is written inside ordinary parentheses, as in WHERE id IN (SELECT id FROM other).

Braces and square brackets have other roles: square brackets delimit identifiers in some dialects, such as SQL Server's [Order Details], and braces appear in ODBC escape sequences - neither encloses a subquery in standard SQL. The parentheses are not decoration; they mark where the inner query ends, which is what lets subqueries nest inside one another.

Please log in or register to report this question.

16.

________ was adopted as a national standard by ANSI in 1992.

Answer: B

Correct answer: SQL

SQL was adopted as an ANSI standard in 1986 and substantially revised as SQL-92, which ANSI adopted in 1992 and which remains the reference point for the language's core.

SQL-92 fixed much of what is now taken for granted: the JOIN syntax in the FROM clause, the % and _ wildcards, and standard data types. The other options are products rather than standards - Oracle, Access and dBase are implementations, and it is precisely the standard that lets skills move between them.

Please log in or register to report this question.

17.

The benefits of a standard relational language include which of the following?

Answer: A

Correct answer: Reduced training costs

A standard language means the skill transfers. Someone who knows SQL can work with Oracle, PostgreSQL, MySQL or SQL Server without learning a new query language for each, so training costs fall and staff are easier to recruit.

The second option states the opposite of a benefit: a standard reduces dependence on a single vendor, since applications can be moved. And applications are certainly still needed - SQL queries the data; it does not supply the interface or the business logic around it.

Please log in or register to report this question.

18.

In SQL, the WHERE clause filters rows before grouping while HAVING filters after grouping.

Answer: B

Correct answer: True

WHERE is applied to individual rows before GROUP BY forms the groups, so it cannot refer to an aggregate. HAVING is applied to the groups afterwards, which is why a condition such as COUNT(*) greater than 5 must go there.

Please log in or register to report this question.

19.

There is an equivalent join expression that can be substituted for all subquery expressions.

Answer: B

Correct answer: False

Some subqueries have no join equivalent. A correlated NOT EXISTS, or a comparison against an aggregate of a related set such as WHERE salary > (SELECT AVG(salary) FROM emp), cannot be expressed as a join.

The reason is structural: a join produces rows by combining them, whereas a subquery can return a single computed value or merely test whether any row exists. Many subqueries can be rewritten as joins, and doing so sometimes helps the optimiser - but the statement claims all of them can, and that is what makes it false.

Please log in or register to report this question.

Answer: B

Correct answer: limits the row data are returned.

WHERE is a filter on rows: it tests each candidate row against a condition and keeps those for which the condition is true.

Which columns come back is decided in the SELECT list instead. The distinction is worth holding onto because the two operations are separate in relational terms - selection chooses rows, projection chooses columns - and SQL expresses them in different clauses. Since WHERE does only the first, the option claiming both is wrong.

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