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. /SQL * Plus commands cannot be abbreviated

  2. /SQL* Plus commands are accessed from a browser.

  3. /SQL*Plus commands are used to manipulate data in tables

  4. /SQL* Plus command manipulate table definitions in the database

  5. /SQL* Plus is the Oracle proprietary interface for executing SQL statements.

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

SQL*Plus is Oracle's command-line interface for executing SQL and PL/SQL statements. Option E correctly identifies it as Oracle's proprietary tool. Option C is correct because SQL*Plus allows you to run SQL statements (DML) to manipulate data in tables. Option A is false because SQL*Plus commands CAN be abbreviated (e.g., DESC for DESCRIBE). Option B is false because SQL*Plus is a command-line tool, not browser-based. Option D is misleading because while you can run DDL through SQL*Plus, table definition manipulation is done via SQL DDL commands, not SQL*Plus-specific commands.

Multiple choice technology web technology
  1. a)It can be used only once in compound query.

  2. The order by clause accepts the column name or an alias

  3. You can specify the order by clause in the subquery of a set operator.

  4. All the above

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

In SQL, the ORDER BY clause can appear only once at the end of a compound query (using UNION, INTERSECT, or EXCEPT) to sort the final combined result. The ORDER BY clause accepts column names or aliases defined in the SELECT list. However, you cannot use ORDER BY in the subqueries that are part of set operators - it would only be allowed in the outer query or with TOP/N clauses in some databases.

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

Multiple choice technology databases
  1. True

  2. False

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

PL/SQL automatically raises NO_DATA_FOUND exception when a SELECT INTO statement returns no rows. This is a predefined exception that triggers when a single-row query fails to find any matching data. Unlike explicit error checking, this built-in mechanism handles empty result sets gracefully.

Multiple choice technology databases
  1. ROW_NUMBER()

  2. RANK()

  3. DENSE_RANK()

  4. NTILE(integer_expression)

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

DENSE_RANK() assigns consecutive ranks (1,2,2,2,3) without gaps after tied values, making it ideal for the requested pattern. ROW_NUMBER() always produces unique sequential numbers (1,2,3,4,5), while RANK() leaves gaps after ties (1,2,2,2,5). NTILE() divides rows into specified number of groups, producing a different pattern entirely.

Multiple choice technology programming languages
  1. Group Left report

  2. Form Like report

  3. Matrix Report

  4. Group above report

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

A Group Left report is a specific layout style where the master (grouping) column is placed to the left of the detail columns. This prevents the master value from repeating for every row of detail data, creating a clean, hierarchical view of the information.