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. CHECK keyword

  2. WITH CHECK keyword

  3. WITH CHECK OPTION keyword

  4. None of the Above

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

The WITH CHECK OPTION clause on a view ensures that any DML operation (INSERT/UPDATE) cannot create rows that the view’s defining query would exclude, protecting against modifications outside the sub‑query’s scope. The other keywords do not provide this restriction.

Multiple choice technology databases
  1. INSERT statement

  2. UPDATE statement

  3. Both of the Above

  4. None of the Above

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

Explicit DEFAULT values can be specified in both INSERT and UPDATE statements to force a column to use its defined default when the supplied value is omitted or set to DEFAULT. Therefore the option indicating both statements is correct; the others omit one context.

Multiple choice technology databases
  1. No. of rows in a table

  2. No. of rows with non-null values of the expr

  3. No. of distinct non-null values of the expr

  4. None of the above

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

COUNT(DISTINCT expr) counts unique non-null values. Unlike regular COUNT which counts total rows, DISTINCT removes duplicates before counting. NULL values are always excluded from the count.

Multiple choice technology databases
  1. Group By

  2. NVL

  3. Order By

  4. Having

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

NVL replaces null values with a specified substitute before aggregation, forcing group functions like SUM or AVG to treat nulls as a concrete value. GROUP BY controls grouping, ORDER BY sorts results, and HAVING filters groups, none of which alter null handling within aggregates.

Multiple choice technology databases
  1. All rows of the Employee table

  2. Rows of the Employee table where the set grade is ‘Y’

  3. Delete 1 row

  4. Nothing will be deleted

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

DELETE with WHERE clause removes only rows matching the condition. It will delete all Employee rows where grade equals 'Y'. If no rows match, nothing is deleted.

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 by how many rows they return: single-row subqueries return one row (use =, >, <), multiple-row subqueries return multiple rows (use IN, ANY, ALL). Option D correctly identifies both types.

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

Single-row subqueries return exactly one row (one column value). They use single-row comparison operators like =, >, <, >=, <=. If they return zero rows, the comparison fails.

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 are used to manipulate data in tables. INSERT adds new rows, UPDATE modifies existing rows, and DELETE removes rows. All three operations are DML commands.