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
-
Bind issue
-
String representation of invalid date value
-
Both A and B
-
No Null indicator
B
Correct answer
Explanation
SQL return code -181 is triggered when a string value cannot be properly converted to a date format. The string representation contains an invalid or unrecognizable date value.
-
Row not found
-
Column not found
-
Both A and B
-
Table not found
D
Correct answer
Explanation
SQL return code -204 is an object not found error. This specifically indicates that the referenced table does not exist in the database, which is different from row or column not found errors.
-
Invalid date and time
-
Missing Null indicator variable
-
Bind issue
-
All the above
B
Correct answer
Explanation
SQL return code -305 indicates that a null indicator variable was not provided for a column that allows null values. When working with nullable columns, the host program must supply an indicator variable to properly handle null values.
-
With Hold option missing
-
Cursor not open
-
Cursor not close
-
BOTH B and C
B
Correct answer
Explanation
SQL code -501 in DB2 indicates that an attempt was made to FETCH or CLOSE a cursor that is not currently open in the application process. Distractors like having a missing WITH HOLD option or attempting to close an already closed cursor do not generate this specific SQL error code.
-
Cursor not closed
-
Cursor not opened
-
Cursor already open
-
ALL the ABOVE
C
Correct answer
Explanation
SQL return code -502 indicates that the application attempted to open a cursor that is already open. A cursor must be closed before it can be opened again - each cursor declaration requires a corresponding CLOSE before reopening.
-
Invalid column values
-
Invalid date or time
-
Update issue. Update clause missing in the select statement of the cursor
-
BOTH A and B
C
Correct answer
Explanation
DB2 SQL error code -503 indicates that an update or delete operation was attempted on a cursor, but the cursor was not defined with a FOR UPDATE clause in its SELECT statement. Other distractors refer to date/time format or value errors.
-
Foreign Key constraint
-
Bind issue
-
Authorization iussue
-
BOTH A and C
A
Correct answer
Explanation
SQL return code -530 is a referential integrity violation indicating a foreign key constraint failure. This occurs when an INSERT or UPDATE operation would create a child row without a valid parent key reference.
-
Restriction in deletion
-
Foreign key constraint
-
Invalid update
-
Both A and B
A
Correct answer
Explanation
SQL return code -532 indicates a deletion restriction due to referential integrity. This occurs when attempting to delete a parent row that has dependent child rows, which would orphan the child records and violate the foreign key constraint.
-
Bind issue
-
Cursor already open
-
Privilege issue
-
All the above
C
Correct answer
Explanation
SQL return code -551 indicates an authorization failure - the user does not have the required privilege to perform the requested operation on the database object. This is an access control error, not a bind issue (which relates to package binding) or a cursor state problem.
-
Column value is not valid
-
Duplicate Value
-
Row not found
-
BOTH A and C
B
Correct answer
Explanation
SQL return code -803 occurs when an INSERT or UPDATE operation attempts to create a duplicate value in a column that has a unique constraint or index. This violates the database's uniqueness rules, preventing the duplicate entry from being stored.
-
Row not found
-
Privilege issue
-
Bind issuie
-
Insert value is missing for a Column
D
Correct answer
Explanation
DB2 SQL error code -117 indicates that the number of values in the INSERT or UPDATE statement is not equal to the number of target columns specified or expected, meaning a value is missing or extra.
-
Column not found
-
Duplicate value
-
Bind issue
-
Invalid time and date
C
Correct answer
Explanation
SQL return code -805 indicates the DB2 package was not found or there's a bind issue - the application program needs to be bound to the database. This relates to program preparation, not column existence, duplicate values, or date validation.
-
Fetching only Zero Rows
-
Fetching more than one row.
-
Table not found
-
BOTH A and B
B
Correct answer
Explanation
SQL return code -811 occurs when a SELECT statement or cursor expects to return exactly one row (as in a singleton SELECT or SELECT INTO) but actually retrieves multiple rows. This is a row count mismatch error.
-
Bind issue
-
No Null indicator found
-
Invalid Date or Time
-
Timestamp mismatch between Load and BIND
D
Correct answer
Explanation
SQL return code -818 indicates a timestamp mismatch between the LOAD and BIND phases in DB2. This happens when the package bound to the database doesn't match the current load module version, requiring a rebind to synchronize them.
-
RESOURCE UNAVAILABLE
-
TABLE NOT FOUND
-
PLAN NOT FOUND
-
ALL THE ABOVE
A
Correct answer
Explanation
SQL return code -904 indicates a resource is unavailable - the database cannot access a required resource like a table space, index space, or physical file. This is different from missing tables (-204) or undefined plans, as it relates to resource accessibility.