Computer Knowledge

Database and SQL

4,213 Questions

Master structured query language commands, database joins, table constraints, and alias generation. This section covers relational database management concepts and query outputs essential for technical aptitude. These technical questions feature prominently in banking IT officer exams and computer knowledge sections.

SQL queries and aliasesDatabase table constraintsDatabase joins and transformationsStored procedures and functions

Database and SQL Questions

Multiple choice technology databases
  1. Single-row subquery, Double-row subquery

  2. Double-row subquery, Multiple-row subquery

  3. Multiple-row subquery

  4. Single-row subquery and Multiple subquery

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Subqueries are categorized into two main types based on the number of rows they return: single-row subqueries (which return exactly one row and use single-row operators like =, >, <) and multiple-row subqueries (which return multiple rows and require operators like IN, ANY, or ALL).

Multiple choice technology databases
  1. Only one row

  2. Two rows

  3. Zero rows

  4. There is no such subquery

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A single-row subquery is designed to return exactly one row from the inner query. This type of subquery can be used with single-row comparison operators like =, >, <, etc. Options B and C are incorrect because they describe multi-row or no-row scenarios, while D is false as single-row subqueries are a valid SQL construct.

Multiple choice technology databases
  1. It gives the name and marks of all the students.

  2. It does not return anything.

  3. It shows an error saying” INVALID SYNTAX ERROR”

  4. It shows an error saying” Single-row subquery returns more than one row

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The subquery uses GROUPBY (should be GROUP BY) on Rollnum, which returns one minimum mark value per unique Rollnum - potentially multiple rows. The outer query uses the single-row comparison operator = with stud_marks, expecting exactly one value. When the subquery returns multiple rows (one per Rollnum group), this creates a mismatch and triggers the 'single-row subquery returns more than one row' error.

Multiple choice technology databases
  1. IN

  2. OF

  3. ALL

  4. ANY

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

ALL is a SQL operator that compares a value to EVERY value returned by a subquery. For example, 'salary > ALL (SELECT salary FROM employees)' means the salary must be greater than every salary in the subquery results. IN checks membership in a set, ANY checks if the condition is true for at least one value, and OF is not a comparison operator.

Multiple choice technology databases
  1. Add new rows to a table

  2. Modify existing rows of a table

  3. Remove existing rows from a table

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

DML (Data Manipulation Language) statements include INSERT (add new rows), UPDATE (modify existing rows), and DELETE (remove existing rows). Since all three operations are DML statements, 'All of the above' is correct. DML commands specifically manipulate data stored in database tables.

Multiple choice technology databases
  1. Insert to table tablename (….);

  2. Insert into table tablename (….);

  3. Insert into table tablename values (…..);

  4. Any one of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The correct SQL syntax for inserting a row is 'INSERT INTO tablename VALUES (...)' or 'INSERT INTO tablename (columns) VALUES (...)'. Option C shows the basic form with VALUES clause. Options A and B use incorrect syntax ('Insert to' and 'Insert into table' instead of 'INSERT INTO'). D is incorrect because not all forms shown are valid.

Multiple choice technology databases
  1. Drop

  2. Create

  3. Alter

  4. Rename

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Teradata MLOAD supports the DROP DDL statement, allowing users to drop tables as part of the MLOAD script. However, MLOAD does not support CREATE, ALTER, or RENAME DDL statements - these must be executed separately outside of MLOAD. MLOAD is optimized for high-volume data loading with limited DDL support, focusing on DELETE and INSERT operations along with DROP for target table management.

Multiple choice technology databases
  1. Return records which have no direct match

  2. Return records which have direct match

  3. Return all the records

  4. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

An outer join returns records from one table even when there's no matching record in the other table. This is useful for finding unmatched records (like customers without orders) or maintaining all records from a primary table.

Multiple choice technology databases
  1. (+)

  2. (-)

  3. (*)

  4. +

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The (+) symbol is the Oracle-specific outer join operator, traditionally used before ANSI standard JOIN syntax was adopted. It's placed on the side of the join condition that may be missing (NULL).

Multiple choice technology databases
  1. Selfjoin

  2. Outerjoin

  3. innerjoin

  4. equijoin

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A self-join joins a table to itself, treating it as if it were two separate tables. This is useful for comparing rows within the same table, such as finding employee-manager relationships in an employees table.