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
-
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.
-
Stored Procedure Not Found
-
General error
-
Duplicate cursor name
-
Option value changed
D
Correct answer
Explanation
SQL470 indicates that an option value has changed, typically referring to database configuration options or settings that were modified during operation. This error occurs when the system detects a discrepancy between expected and actual option values. Options A, B, and C refer to different database error scenarios (missing procedures, general failures, cursor naming conflicts).
-
DDL not allowed on this table definition
-
Column with this name already exists
-
View's WITH CHECK OPTION validation failed in UPDATE
-
One or more matching rows is locked by another user
A
Correct answer
Explanation
In SQL Anywhere and Sybase databases, the SQL300 error code indicates that DDL (Data Definition Language) operations are not allowed on the specified table definition.
-
Invalid field name
-
Invalid table name
-
Invalid index name
-
Invalid view name
B
Correct answer
Explanation
SQL87 specifically indicates an invalid table name error, meaning the SQL statement references a table that doesn't exist, is misspelled, or the user lacks permissions to access it. This is distinct from other object naming errors - options A, C, and D refer to fields, indexes, and views respectively, which would produce different error codes. The table name validation happens early in SQL parsing.
-
Cursor not updateable
-
DISTINCT not valid in subquery of FROM clause
-
Positive integer constant or variable expected
-
Incompatible SELECT list is used in INSERT
D
Correct answer
Explanation
In Sybase and SQL Anywhere, the SQL64 error code indicates that an incompatible SELECT list is used in an INSERT statement, meaning the columns returned do not match the destination table columns.