Computer Knowledge

Database and SQL

3,929 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 Functions and Double-row Functions

  2. One-row Functions and Two-row Functions

  3. Single-row Functions and Multiple-row Functions

  4. None of the above

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

SQL functions are broadly categorized into single-row functions, which operate on single rows and return one result per row, and multiple-row (or group/aggregate) functions, which operate on sets of rows to return a single result. Double-row or two-row functions do not exist.

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

Outer joins (LEFT, RIGHT, FULL) are specifically designed to return unmatched rows from one or both tables, along with matched rows. This is their defining purpose - unlike inner joins which only return matches. Option A correctly identifies this behavior.

Multiple choice technology databases
  1. (+)

  2. (-)

  3. (*)

  4. +

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

In Oracle SQL syntax, the (+) operator is placed next to the column that may be null to indicate an outer join. For example, 'WHERE table1.id = table2.id(+)' creates a right outer join. This is Oracle's legacy outer join syntax.

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, typically using table aliases to treat it as two separate copies. This is used for hierarchical data (employee-manager) or comparing rows within the same table. Option A correctly names this join type.

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 classified as single-row (return one row) or multiple-row (return multiple rows). This classification determines which operators you can use: single-row operators (=, >, <) vs multiple-row operators (IN, ANY, ALL). Option D is correct despite slightly awkward phrasing.

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 returns exactly one row from the inner query, allowing use of single-row comparison operators like =, >, <, >=, <=, !=. If it returns zero or multiple rows, these operators will cause an error.

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 GROUP BY Rollnum, which returns one row per unique Rollnum (multiple rows total). The outer query uses = (single-row operator), which cannot handle multiple results. This triggers the error 'single-row subquery returns more than one row'. Note: GROUPBY should be GROUP BY (missing space).

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) includes INSERT (add new rows), UPDATE (modify existing rows), and DELETE (remove existing rows). All three actions are DML operations, so 'All of the above' is correct.

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

Correct INSERT syntax is INSERT INTO tablename VALUES (...). Option A has 'Insert to' instead of 'Insert into'. Option B is missing the VALUES keyword. Option C is correct: INSERT INTO tablename VALUES (...). Note: Option C says 'Insert into table tablename' which has an extra 'table' - the standard is just 'INSERT INTO tablename VALUES (...)'.