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 mainframe
  1. BOTH B and C

  2. Privilege issue

  3. Dead Lock

  4. No row found

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

SQL return code -911 indicates a deadlock or timeout situation - the transaction has been rolled back due to a deadlock with another transaction or because it exceeded the lock timeout limit. This is a concurrency issue, not a privilege problem or missing rows.

Multiple choice technology mainframe
  1. Access not given

  2. Plan not found

  3. Deadlock and Timeout

  4. Authorization isse

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

SQL return code -913 in DB2 indicates that the current transaction was rolled back due to a deadlock or timeout. This error occurs when multiple processes are competing for the same resources, causing the system to terminate one to resolve the conflict. The other options are incorrect: -911 would be for a rollback, -802/803 for access violations, and -551 for authorization issues.

Multiple choice technology mainframe
  1. Dead Loack

  2. Time out

  3. BOTH A and D

  4. Authorization failure

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

DB2 SQL error code -922 indicates an authorization or connection failure, specifying that authorization is denied for the plan or connection type. Code -911 or -913 typically represents deadlocks and timeouts.

Multiple choice technology mainframe
  1. Colum not found

  2. Rows found

  3. No Row found

  4. Both A and B

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

SQL return code +100 means no row was found or the cursor is positioned after the last row of the result set. This is the expected outcome when a SELECT INTO or FETCH finds no matching data. Option A describes a different error (column not found would be -206), and option B is incorrect because +100 specifically indicates the absence of rows.

Multiple choice technology mainframe
  1. We can override parameters on EXEC statements and add DD statements.

  2. We can override, nullify and add parameters on all statements and add DD and/or OUTPUT

  3. We can add and override parameters to all statements, but can only nullify parameters

  4. We can nullify, override and add parameters to all statements, but can only add DD statements.

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

In JCL, modifying a called procedure is highly flexible. You can override parameters, nullify them, or add new parameters on all JCL statements within the proc, and add entire DD or OUTPUT statements. Other options artificially limit these capabilities.

Multiple choice technology databases
  1. Right to Left processing of Source (Tables, views etc.) by Parser

  2. Left to Right processing of Source (Tables, views etc.) by Parser

  3. Bottom to Up processing of WHERE condition clauses

  4. Up to Bottom processing of WHERE condition clauses

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

The SQL parser processes tables/views right-to-left (starting with the rightmost table). WHERE clause conditions are evaluated bottom-to-top, so the last condition is evaluated first. This ordering affects how the optimizer constructs the execution plan.

Multiple choice technology databases
  1. Using NULL / NOT NULL on indexed columns won’t use INDEX

  2. Using NULL / NOT NULL on indexed columns gives ERROR

  3. Using NULL / NOT NULL on indexed columns disables INDEX

  4. Using NULL / NOT NULL on indexed columns makes the INDEX unusable

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

When you use NULL or NOT NULL on an indexed column, the optimizer typically chooses a full table scan instead of using the index. This is because NULL values are not stored in most B-tree indexes (except bitmap indexes), making the index ineffective for NULL searches.

Multiple choice technology security
  1. a code injection technique that exploits a security vulnerability occurring in the database layer of an application

  2. is a type of computer security vulnerability typically found in web applications that enables malicious attackers to inject client-side script into web pages viewed by other users

  3. is a way to allow users to query database using web

  4. is a latest way to fight against database security issues

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

SQL Injection attacks work by inserting malicious SQL code into input fields, which the database then executes. This allows attackers to bypass authentication, retrieve sensitive data, or modify/delete database content. Unlike XSS which targets client-side scripts, SQLi specifically targets the database layer of an application.

Multiple choice technology databases
  1. Equi Join

  2. Outer Join

  3. Non-Equi Join

  4. Cartesian Join

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

Cartesian Join (Cross Join) produces every possible combination of rows from both tables - if Table A has 100 rows and Table B has 1000 rows, the result is 100,000 rows. This exponential growth creates massive memory and CPU overhead. Equi Join, Outer Join, and Non-Equi Join all use join conditions to limit the result set, making them far more efficient than Cartesian products.

Multiple choice technology databases
  1. PLAN

  2. EXPLAIN PLAN

  3. TKPROF

  4. V$PLAN
Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

EXPLAIN PLAN is the SQL command that generates and displays the execution plan for a SQL statement without actually executing it. PLAN is not a valid command, TKPROF is a profiling tool for analyzing trace files, and V$PLAN is not a valid dynamic performance view.

Multiple choice technology databases
  1. select nvl(to_char(comm),'NA') from emp;

  2. select nvl(comm,'NA') from emp;

  3. select nvl(comm,NA) from emp;

  4. None of the above

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

The NVL function requires both parameters to have compatible data types. Since 'commission' is numeric and 'NA' is a string, we must first convert commission to character using TO_CHAR, then apply NVL. The correct syntax is nvl(to_char(comm),'NA'). Option B fails because nvl(comm,'NA') tries to substitute a string into a numeric column, and Option C has no quotes around NA.

Multiple choice technology databases
  1. True

  2. False

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

A transaction in Oracle is defined as a logical unit of work that begins with the first SQL statement after a COMMIT or ROLLBACK (or at session start) and ends with the next COMMIT or ROLLBACK. This definition is correct - transactions span the statements BETWEEN two commit/rollback points.

Multiple choice technology databases
  1. Yes

  2. No

  3. Not in Oracle

  4. None of the above

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

CHECK constraints can enforce conditions on columns including self-referential logic within the same row. A CHECK constraint can reference other columns in the same table to validate row-level data integrity. For example, CHECK (end_date >= start_date) ensures referential integrity within the row itself.

Multiple choice technology databases
  1. Yes

  2. No

  3. Not in Oracle

  4. None of the above

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

The SELECT-INTO statement in PL/SQL can fetch values into a record variable. When x is a record with components matching the selected columns (sal as NUMBER(4) and ename as CHAR(15)), this is perfectly valid syntax. The query will populate the record fields with the retrieved values.