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

Multiple choice technology databases
  1. Structured Query Language

  2. Standard Query Language

  3. System Query Language

  4. Simple Query Language

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

SQL stands for Structured Query Language. It's the standard language for relational database management systems used to query, manipulate, and define data.

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 multiple MIN(stud_marks) values (one per unique rollnum). When compared with a single value using = in the WHERE clause, this causes the error 'single-row subquery returns more than one row' because the main query expects exactly one value to compare against.

Multiple choice technology databases
  1. Projection

  2. Selection

  3. Join

  4. All of the above

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

SQL SELECT statements have three main capabilities: Projection (selecting specific columns), Selection (filtering rows with WHERE), and Join (combining data from multiple tables). All of these are fundamental SELECT operations.

Multiple choice technology databases
  1. Select all columns from EMP;

  2. Select distinct columns from EMP;

  3. Select * from EMP;

  4. All of the above

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

To retrieve every column from a table, the standard SQL syntax uses the asterisk wildcard: SELECT * FROM EMP;. The phrase “Select all columns from EMP;” is not valid SQL, and SELECT DISTINCT applies to rows, not columns. Therefore only the asterisk option is correct.

Multiple choice technology databases
  1. They don't have to be a Primary Index column

  2. They are not allowed to be a Primary Index column.

  3. They are required to be a Non-Unique Primary Index

  4. You can only specify one Identity Column per table.

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

Identity columns in Teradata are independent of the Primary Index - they can be defined on non-PI columns. They are also allowed to be part of the PI, contradicting option B. Teradata enforces a strict limit of one identity column per table to maintain data integrity and avoid ambiguity in auto-generation.

Multiple choice technology databases
  1. All columns required by the query are available via the Primary index.

  2. All columns required by the query are available via a Join Index.

  3. All columns required by the query are available via the Hash Index

  4. The PE covers the query by looking into cache to see if the same query has been run in the last 240 minutes. If it has been cached the PE doesn't have to generate steps for the AMPs.

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

A Cover Query is optimized to retrieve all required columns directly from a Join Index without accessing the base table. Join Indexes pre-join and store frequently queried column combinations, allowing the optimizer to satisfy queries entirely from the index structure. This eliminates expensive joins and dramatically improves performance.

Multiple choice technology databases
  1. Join Indexes have repeating values.

  2. Join Indexes do not have repeating values.

  3. Join Indexes are updated automatically when their underlying rows change

  4. Join Indexes are not updated automatically when their underlying rows change.

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

Join Indexes store pre-joined data from multiple tables, naturally resulting in repeating values as the join relationship creates duplicates. Teradata automatically maintains Join Indexes when underlying base table rows change, ensuring the pre-joined data stays synchronized without manual intervention.