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
-
BOTH B and C
-
Privilege issue
-
Dead Lock
-
No row found
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.
-
Access not given
-
Plan not found
-
Deadlock and Timeout
-
Authorization isse
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.
-
Dead Loack
-
Time out
-
BOTH A and D
-
Authorization failure
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.
-
Colum not found
-
Rows found
-
No Row found
-
Both A and B
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.
-
We can override parameters on EXEC statements and add DD statements.
-
We can override, nullify and add parameters on all statements and add DD and/or OUTPUT
-
We can add and override parameters to all statements, but can only nullify parameters
-
We can nullify, override and add parameters to all statements, but can only add DD statements.
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.
-
Right to Left processing of Source (Tables, views etc.) by Parser
-
Left to Right processing of Source (Tables, views etc.) by Parser
-
Bottom to Up processing of WHERE condition clauses
-
Up to Bottom processing of WHERE condition clauses
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.
-
Using NULL / NOT NULL on indexed columns won’t use INDEX
-
Using NULL / NOT NULL on indexed columns gives ERROR
-
Using NULL / NOT NULL on indexed columns disables INDEX
-
Using NULL / NOT NULL on indexed columns makes the INDEX unusable
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.
-
a code injection technique that exploits a security vulnerability occurring in the database layer of an application
-
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
-
is a way to allow users to query database using web
-
is a latest way to fight against database security issues
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.
-
Equi Join
-
Outer Join
-
Non-Equi Join
-
Cartesian Join
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.
-
PLAN
-
EXPLAIN PLAN
-
TKPROF
-
V$PLAN
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.
-
select nvl(to_char(comm),'NA') from emp;
-
select nvl(comm,'NA') from emp;
-
select nvl(comm,NA) from emp;
-
None of the above
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.
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.
-
Yes
-
No
-
Not in Oracle
-
None of the above
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.
-
Yes
-
No
-
Not in Oracle
-
None of the above
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.