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. The SQL statements in the IF condition are processed.

  2. The SQL statements in the ELSE condition are processed.

  3. IF-THEN-ELSE-ENDIF construct is skipped.

  4. The SQL statements in the IF condition as well as ELSE condition are processed.

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

When the IF condition evaluates to NULL in PL/SQL, it's treated as FALSE and the entire IF-THEN-ELSE construct is skipped - neither the IF nor ELSE blocks execute. PL/SQL doesn't process NULL as a separate logical state in conditional constructs.

Multiple choice technology databases
  1. Cursors

  2. Cursor For Loop

  3. Simple Loop

  4. Exit Loop

  5. Numeric For Loop

  6. While Loop

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

PL/SQL iterative control constructs include Cursor For Loop (iterates over cursor rows), Simple Loop (basic LOOP with EXIT), Numeric For Loop (iterates over number range), and While Loop (condition-based iteration). Cursors themselves aren't loops, and Exit Loop isn't a standalone construct.

Multiple choice technology databases
  1. Cursor For Loop

  2. Numeric For Loop

  3. While Loop

  4. Simple Loop

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

Simple Loop is called an infinite loop because it has no built-in termination condition. It continues indefinitely until explicitly exited using an EXIT or EXIT WHEN statement. Unlike For Loops (with counter limits) or While Loops (with conditions), Simple Loop relies entirely on manual exit logic.

Multiple choice technology web technology
  1. Loop

  2. IF-THEN-ELSE-ENDIF construct

  3. Block

  4. Exception

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

Statement labels in PL/SQL can name loops and blocks for control flow purposes like EXIT label_name or GOTO label_name. They cannot be used with IF-THEN-ELSE constructs or exception handlers directly - those structures use END IF and END exception_name instead.

Multiple choice technology databases
  1. All INSERT statements

  2. All DELETE statements

  3. All UPDATE statements

  4. Single row SELECT statements

  5. Multiple row SELECT statements

  6. Zero row SELECT statements

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

Implicit cursors are automatically created by PL/SQL for all single-row DML operations (INSERT, UPDATE, DELETE) and single-row SELECT...INTO statements. Multi-row SELECT statements require explicit cursors with loops to process multiple rows.

Multiple choice technology databases
  1. %FOUND

  2. %NOTFOUND

  3. %ROWCOUNT

  4. %ISOPEN

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

The %ROWCOUNT attribute returns the number of rows fetched so far by an open cursor or affected by DML statements. In contrast, %FOUND and %NOTFOUND are boolean attributes indicating whether a row was fetched, and %ISOPEN returns a boolean indicating whether the cursor is open or closed.

Multiple choice technology databases
  1. %FOUND

  2. %NOTFOUND

  3. %ROWCOUNT

  4. %ISOPEN

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

%NOTFOUND evaluates to TRUE when a FETCH operation fails to return a row (no more rows), and FALSE when at least one row is successfully returned. This attribute is commonly used to check if a cursor has exhausted its rows after a fetch operation. %FOUND does the opposite (TRUE when a row is found).

Multiple choice technology databases
  1. 'asi'

  2. 'isa'

  3. 'le '

  4. 'acl'

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

SUBSTR('Oracle Basics', -5, 3) starts 5 characters from the end, giving 'sics' starting from position -5, then extracts 3 characters: 'asi'. Negative positions count from the string's end. So position -5 is 's', -4 is 'i', -3 is 'c', -2 is 's', -1 is the last character. Starting at -5, three characters gives 'asi'.

Multiple choice technology databases
  1. 300

  2. 100

  3. 500

  4. 000

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

The MOD function returns the remainder when the first number is divided by the second. Here, 1600 divided by 300 equals 5 with a remainder of 100 (since 300 × 5 = 1500). Option B correctly shows 100 as the remainder. Options A and C (300 and 500) are the divisor and a multiple respectively, while D (000) is just a formatting variation of zero.

Multiple choice technology databases
  1. sum

  2. num_rows

  3. count

  4. total

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

The COUNT() function is specifically designed to return the number of rows in a result set or table. SUM adds numeric values, num_rows is not a standard SQL function (it may exist in specific programming interfaces), and 'total' is not a built-in SQL function. COUNT is the universal SQL method for row counting.

Multiple choice technology databases
  1. User Defined Exception

  2. Predefined Internal Exception --- NO_DATA_FOUND

  3. Predefined Internal Exception --- VALUE_ERROR

  4. OTHERS Exception

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

The WHEN OTHERS exception handler is a catch-all block that handles any exceptions not explicitly caught by preceding handlers. Because it catches everything, it must be the last handler in a PL/SQL exception block.