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
-
01-Jan-08
-
22-Sep-08
-
01-Sep-08
-
None of above
-
Not Null
-
Check
-
Unique key
-
All of above
C
Correct answer
Explanation
Unique key constraints require an index to enforce uniqueness efficiently. NOT NULL constraints and CHECK constraints do not require indexes - they're validation rules. Therefore, only unique keys (C) mandatorily require an index.
-
It process tuples one by one
-
It can be used in PLSQL
-
It can use SET operators
-
None of above
D
Correct answer
Explanation
SQL is a set-oriented language because it operates on entire sets of data (relations) at once, rather than processing individual records or tuples one by one like procedural languages.
B
Correct answer
Explanation
The statement is false because NULL values mapping to non-nullable target fields MUST be handled in code through validation logic, default value assignment, or data cleansing rules. Without such handling, the ETL process would fail with constraint violations when attempting to insert NULL into NOT NULL database columns.
-
SQL System Error
-
SQL Data base error
-
SQL numeric error
-
None of the these
A
Correct answer
Explanation
SQL0901 is the DB2 SQL error code for 'SQL System Error' - a generic error indicating an unexpected system-level failure in the database engine. It's not a data-specific error (SQLCODE -204, -208 for object/column not found) or a numeric error - it's a catch-all for internal DB2 problems.
-
Database error
-
MYSYSCONF not found
-
ORDER BY column not in result table
-
not valid for naming convention
B
Correct answer
Explanation
SQL0204 in DB2 means the specified object (name in the error) was not found in the database. While the option shows 'MYSYSCONF not found', this is the specific message for SQLCODE -204. The other options don't match: SQL0204 is about undefined objects, not naming conventions or ORDER BY issues (that's SQLCODE -208).
-
interger not found
-
Numeric not allowed
-
Name &1 not allowed.
-
ORDER BY column not in result table
D
Correct answer
Explanation
SQL0208 is the DB2 error code for 'ORDER BY column not in result table' - you're trying to sort by a column that doesn't exist in your SELECT list. This is a common SQL error when the ORDER BY clause references a non-existent column or alias. The other options don't match: it's not about integers, numerics, or naming conventions.
-
Constraint or Key not found
-
Foreign key references non-existent table
-
Before Delete trigger failed
-
Row to DELETE not found
B
Correct answer
Explanation
In Sybase and SQL Anywhere, the SQL310 error code indicates that a foreign key references a non-existent table, violating referential integrity constraints during schema definition.
-
Trigger not found
-
Trigger name not unique
-
Trigger with same EVENT, TIME, and ORDER already defined
-
Fatal Connection error
A
Correct answer
Explanation
SQL363 is a database-specific error code indicating that a referenced trigger could not be found in the database schema. This typically occurs when a SQL statement attempts to use a trigger that has been dropped, renamed, or was never created. Option B refers to a different trigger-related error (duplicate names), while option C describes a trigger conflict scenario that would produce a different error code.
-
Numeric expected
-
Integer expected
-
Column Constraint expected
-
Invalid table name
B
Correct answer
Explanation
SQL89 indicates that the database system expected an integer value but received a different data type. This error commonly occurs when a non-integer value is provided in a context requiring an integer, such as an integer column or parameter. Option A (Numeric expected) is related but less specific than Integer expected, while options C and D refer to completely different error categories.
-
Fatal error occurred
-
%THRESHOLD Violation
-
Privilege Violation
-
Access violation
D
Correct answer
Explanation
SQL112 represents an access violation error, indicating that a user or process attempted to access a database resource (table, view, procedure, etc.) without proper permissions. This is distinct from privilege violations (option C) and is specifically about unauthorized access attempts rather than permission configuration issues. Options A and B refer to completely different error categories.
-
Unknown or non-unique User or Role
-
Cannot INSERT/UPDATE/DELETE on a read only table
-
Row to DELETE not found
-
Operation Disallowed by Operation Table
A
Correct answer
Explanation
SQL118 indicates an unknown or non-unique user or role reference, meaning the database cannot identify a specific user or role, or the name provided matches multiple users/roles. This commonly occurs during permission operations, authentication, or when referencing users in SQL statements. Options B, C, and D refer to completely different database error scenarios.
-
After Delete trigger failed
-
Before Delete trigger failed
-
Before Update trigger failed
-
Before Insert trigger failed
D
Correct answer
Explanation
SQL130 specifically indicates that a 'Before Insert' trigger has failed during execution. This error occurs when the trigger logic encounters an error while processing data before it's inserted into the table. The other options refer to different trigger timing events (After Delete, Before Delete, Before Update) which would produce different error codes.
-
Multi-Line Field not valid in ORDER BY clause
-
Multi-Line Field must be the Left operand of the Comparison
-
Multi-Line Field only valid for LIKE, Contains ([), or NULL Comparison
-
None of these
A
Correct answer
Explanation
SQL72 indicates that a multi-line text field cannot be used in an ORDER BY clause because multi-line fields don't have a well-defined sorting order. The database engine cannot determine how to properly sort rows based on multi-line content. Options B and C describe other potential multi-line field restrictions that would apply in different contexts, while option D is incorrect since option A accurately describes the error.
-
Duplicate cursor name
-
Unable to receive server message
-
Invalid Stored Procedure Name
-
None of these
A
Correct answer
Explanation
In Sybase and SQL Anywhere, the SQL471 error code indicates a duplicate cursor name, meaning an attempt was made to open or declare a cursor with a name that is already in use.