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

  2. Two

  3. One

  4. 64

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

Teradata requires exactly one Primary Index per table. This PI (which can be single-column or composite) determines how rows are distributed across AMPs. A table cannot have multiple PIs or zero PIs - the system uses this single PI for all data distribution and retrieval operations.

Multiple choice technology
  1. Chasm Trap

  2. Fan Trap

  3. Loop

  4. Context

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

A Chasm Trap occurs when two many-to-one joins converge on a single table, causing the query to return more rows than expected (a Cartesian multiplication effect). This happens because aggregations get lost or duplicated at the convergence point. A Fan Trap involves one-to-many joins diverging, while a Loop is a circular join path.

Multiple choice technology
  1. Shortcut Join

  2. Outer Join

  3. Inner Join

  4. Full Join

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

A Shortcut Join creates a direct alternative path between two tables, bypassing intermediate tables in the join path. This improves query performance by reducing the number of joins the database engine must execute. The other options are standard SQL join types that don't specifically provide optimized alternative routes.

Multiple choice technology databases
  1. True

  2. False

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

Views cannot be specified in trigger statements because triggers require base table events to fire properly. A view is a derived object that doesn't directly support the event-based nature of triggers. Triggers must be associated with actual tables that generate the events (INSERT, UPDATE, DELETE).

Multiple choice technology databases
  1. True

  2. False

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

PL/SQL supports function overloading, which allows multiple functions to share the same name within the same block or package scope. The functions must have different parameter signatures (different number, order, or data types of parameters) so the compiler can distinguish which version to invoke based on the arguments provided.

Multiple choice technology databases
  1. WHERE

  2. ORDER BY

  3. GROUP BY

  4. Aggregate Function

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

When using aggregate functions like SUM, COUNT, AVG in SQL's SELECT clause, non-aggregated columns must be included in a GROUP BY clause. This groups rows before aggregation. WHERE filters rows before grouping, ORDER BY sorts results after aggregation. The 'Aggregate Function' option is not a clause.

Multiple choice technology databases
  1. MSUM

  2. SUM

  3. AVG

  4. All of the above

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

MSUM is an OLAP (Online Analytical Processing) function used in data warehousing for calculating moving sums across dimensions. While SUM and AVG are standard SQL aggregate functions, they are not specifically OLAP functions. OLAP functions operate across data cubes and dimensions for analytical processing, not simple row aggregation.

Multiple choice technology databases
  1. Volatile Table

  2. Global Temporary table

  3. MultiSet Table

  4. Permanent Table

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

In Teradata SQL, a Multiset table allows duplicate rows to be stored. Volatile tables are temporary session-specific tables. Global Temporary tables are also temporary. Permanent tables (default) typically enforce uniqueness constraints. The Multiset table type specifically permits duplicate rows, which is useful for certain data scenarios like logs or staging data.

Multiple choice technology databases
  1. Secondary Index

  2. First unique column in the table

  3. Primary key

  4. First non-unique coulmn in the table

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

In Teradata, if a Primary Key is defined but no Primary Index is specified during table creation, the system automatically uses the Primary Key as the Primary Index. The Primary Index determines data distribution across AMPs (Access Module Processors). Options A, B, and D are incorrect - it doesn't default to secondary index, first unique column, or first non-unique column.

Multiple choice technology databases
  1. Permanent Table

  2. Set Table

  3. Multiset Table

  4. Volatile Table

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

Volatile tables are temporary tables that exist only for the duration of a session. Since they are automatically dropped at session end and used for transient data, Teradata does not collect statistics on them. Permanent tables, multiset tables, and set tables all support statistics collection.