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 web technology
  1. AVG

  2. COUNT

  3. MAX

  4. STDDEV

  5. LENGTH

  6. All the above.

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

SQL GROUP functions (also called aggregate functions) perform calculations on sets of rows and return a single result. AVG, COUNT, MAX, and STDDEV are all GROUP functions that compute statistics across multiple rows. LENGTH, however, is a single-row function that operates on individual string values, not groups. The option 'All the above' is incorrect because it includes LENGTH which doesn't belong to GROUP functions.

Multiple choice technology web technology
  1. True

  2. False

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

In Oracle SQL, the UNIQUE and BITMAP keywords cannot be used together when creating an index. UNIQUE enforces that all index key values must be distinct, while BITMAP creates a bitmap index optimized for low-cardinality columns with few distinct values. These are fundamentally different index types with different use cases, so they're mutually exclusive. You must choose one or the other, not both.

Multiple choice technology
  1. Adds all the numbers in a range of cells.

  2. Adds up cell values based on a condition.

  3. Returns a subtotal in a list or database.

  4. None of the above.

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

SUMIF adds values that meet a specified condition, unlike SUM which adds all values unconditionally. It requires a range to test, a criteria to match, and an optional range to sum.

Multiple choice technology databases
  1. Unique constraints

  2. Primary keys

  3. Cascading actions

  4. Foreign keys

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

Referential integrity ensures relationships between tables remain consistent. Primary keys, foreign keys, and cascading actions (like ON DELETE CASCADE) are core mechanisms for this. Unique constraints ensure data uniqueness but do not inherently manage relationships between different tables.

Multiple choice technology databases
  1. A View of a table

  2. an alternate name for a table

  3. A Secondary table

  4. A Primary table

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

In database terminology, a synonym is an alternate name for a database object like a table. It can function as a view-like alias (option A) or simply as an alternative reference name (option B). It is not a separate table, primary or secondary.

Multiple choice technology databases
  1. The relation of the primary key of a base table with foreign key of the reference table is known as referential integriety.

  2. The relation of the secondary key of a base table with foreign key of the reference table is known as referential integriety.

  3. The relation of the primary key of a secondary table with foreign key of the reference table is known as referential integriety.

  4. The relation of the primary key of a base table with index key of the reference table is known as referential integriety.

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

Referential integrity is a database concept that ensures relationships between tables remain consistent. It is maintained by defining a Foreign Key in a child (reference) table that must match a Primary Key in the parent (base) table, ensuring no orphaned records exist.

Multiple choice technology databases
  1. True

  2. False

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

In PL/SQL, every block (anonymous blocks, procedures, functions, and packages) can have its own EXCEPTION section to handle errors that occur within that specific block. This allows for modular error handling where different blocks can manage exceptions differently based on their context.

Multiple choice technology databases
  1. Type of Exception

  2. Finally block

  3. An Error Code

  4. A message

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

PL/SQL exception messages contain three key components: the exception type (such as NO_DATA_FOUND or VALUE_ERROR), an error code (numeric identifier like ORA-01403), and a descriptive message explaining the error. A FINALLY block is a separate construct used in some languages for cleanup code but is not part of the exception message itself in PL/SQL.

Multiple choice technology databases
  1. Named System Exceptions

  2. Unnamed System Exceptions

  3. Implicit Exceptions

  4. Explicit Exceptions

  5. User-defined Exceptions

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

PL/SQL exceptions are categorized into three types: Named System Exceptions (pre-defined by Oracle), Unnamed System Exceptions (handled via Pragma EXCEPTION_INIT), and User-defined Exceptions (declared by the developer for specific business logic). 'Implicit' and 'Explicit' refer to how they are raised, not their type.

Multiple choice technology databases
  1. Not Declared explicitly

  2. Raised implicitly when a predefined Oracle error occurs

  3. caught by referencing the standard name within an exception-handling routine

  4. All of the above

  5. None of the above

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

Named system exceptions in PL/SQL (like NO_DATA_FOUND, TOO_MANY_ROWS, DUP_VAL_ON_INDEX) are predefined exceptions that don't require explicit declaration, are raised automatically when specific Oracle errors occur, and are caught by referencing their standard names in exception handlers. These are built into the PL/SQL language for common error conditions.

Multiple choice technology databases
  1. DECLARE

  2. RAISE

  3. PRAGMA

  4. INITIATE

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

In PL/SQL, user-defined exceptions must be explicitly raised using the RAISE statement when the error condition occurs. Unlike predefined exceptions that are raised automatically by Oracle, your custom exceptions need manual triggering with RAISE exception_name;. This allows controlled error handling for application-specific conditions.

Multiple choice technology databases
  1. Hardware failures

  2. Design faults

  3. Coding mistakes

  4. None of the above

  5. All of the above

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

Run-time errors can originate from multiple sources including hardware failures (disk crashes, memory errors), design faults (logic errors, incorrect requirements interpretation), and coding mistakes (syntax errors, boundary violations). The most comprehensive answer recognizes that all these categories contribute to run-time error conditions.

Multiple choice technology databases
  1. internal, explicitly

  2. internal, implicitly

  3. user-defined, explicitly

  4. user-defined, implicitly

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

Internal exceptions (like NO_DATA_FOUND or ZERO_DIVIDE) are raised implicitly by the Oracle runtime engine whenever a program violates a database rule. User-defined exceptions, conversely, are typically raised explicitly by the programmer using the RAISE statement.