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

  2. 69

  3. 1

  4. None

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

In Oracle, when you GROUP BY ROWNUM, it groups by the rownum values. With 100 rows, you get rownum values 1 through 100. The HAVING clause filters to show only the group where rownum equals 69, so it returns a single row with value 69. ROWNUM is a pseudocolumn assigned as rows are retrieved.

Multiple choice technology databases
  1. A

  2. B

  3. C

  4. None

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

All three DELETE statements are syntactically valid in Oracle. 'DELETE FROM emp;' is the standard syntax. 'DELETE emp;' is a valid shorthand (FROM is optional). 'DELETE FROM emp WHERE 1=1;' is valid but the WHERE clause is redundant since 1=1 is always true. All three would delete all 10 rows successfully.

Multiple choice technology databases
  1. It throws error

  2. it will give 8th row

  3. no rows will get displayed

  4. None

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

In Oracle, ROWNUM is assigned to rows as they are retrieved, starting from 1. A query like 'WHERE ROWNUM=8' tries to find the 8th row, but ROWNUM is assigned incrementally. By the time any row could potentially be the 8th row, ROWNUM values 1-7 haven't been satisfied, so the condition never matches. The query returns no rows.

Multiple choice technology databases
  1. Joiner

  2. Lookup

  3. Source Qualifier

  4. All

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

Lookup transformation is used to check if a record exists in the target table. It queries a cached version of the target table and returns matching rows based on the lookup condition. This is commonly used for incremental loading (checking for duplicates before insert) or slowly changing dimensions (determining if a row exists before update). Joiner combines two sources in the pipeline, and Source Qualifier operates at the source database level.

Multiple choice technology mainframe
  1. 66

  2. 77

  3. 88

  4. 90

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

In COBOL, level 66 is specifically reserved for the RENAMES clause, which regroups previously defined data items. Level 77 is used for independent elementary items, level 88 is for condition names, and level 90 is not a standard level number.

Multiple choice technology mainframe
  1. 66

  2. 77

  3. 88

  4. 90

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

COBOL uses level numbers to define data structure, and level 66 is specifically designated for the RENAMES clause. This clause allows you to group existing data items under an alternative name, providing a way to treat a subset of data as a single logical unit without redefining the underlying data structure.

Multiple choice technology
  1. Random Column Propogation

  2. Remove Column Propogate

  3. Runtime Column Propogation

  4. Real-time Column Propogation

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

RCP in Datastage stands for Runtime Column Propagation. This feature automatically propagates column metadata at runtime without needing to define all columns in schema. The other options (Random, Remove, Real-time) are incorrect.

Multiple choice technology databases
  1. Normalization

  2. Data Integrity

  3. Materialized Views

  4. None of these

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

ON UPDATE CASCADE is a referential integrity constraint that automatically updates dependent rows when a referenced primary key is updated. This ensures data consistency across related tables, preventing orphaned records and maintaining the integrity of relationships. Options A and C describe different database concepts (normalization and materialized views).

Multiple choice technology databases
  1. True

  2. False

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

When a NULL value appears in a NOT IN subquery or list, the entire condition evaluates to UNKNOWN for all rows because comparing any value to NULL (except with IS NULL) returns UNKNOWN, which falsifies the AND condition. This causes the query to return zero rows, not any rows as the statement suggests.

Multiple choice technology databases
  1. NOT, Parenthesis AND, OR

  2. Parenthesis,NOT, AND, OR

  3. Parenthesis, OR ,NOT, AND

  4. Parenthesis,NOT, OR, AND

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

SQL operators follow the standard precedence: parentheses override all other grouping, NOT is evaluated before AND, and AND is evaluated before OR. This order ensures that expressions like 'A OR B AND C' are evaluated as 'A OR (B AND C)' rather than '(A OR B) AND C'.

Multiple choice technology databases
  1. True

  2. False

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

While GROUP BY is commonly used with aggregates and non-aggregates, it's not the only approach. Window functions can combine aggregates with non-aggregated data without GROUP BY. Additionally, some databases allow mixing aggregates and non-aggregates when non-aggregates are functionally dependent on GROUP BY columns.

Multiple choice technology databases
  1. Self Join

  2. Cartesian Join

  3. Cross Join

  4. Hash Join

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

A self-join requires treating a single table as if it were multiple tables using different aliases (e.g., employees e1 JOIN employees e2), which can be conceptualized as denormalization for the join operation. Unlike other join types that combine distinct tables, a self-join operates on one table by creating virtual copies through aliasing.