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
-
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.
-
COMMAND NOT SPECIFIED
-
ALREADY LOGGED IN
-
SESSION DOES NOT EXIST
-
None of these
A
Correct answer
Explanation
SQL1401 indicates that a required command was not specified in the SQL statement being executed. This error occurs when the database system expects a command but none is provided.
-
FAILED TO RETAIN COOPERATIVE TASK
-
FAILED TO LOAD INFILE
-
FAILED TO PUT SQL LOCK ON A TABLE
-
FAILED TO LOCK RECORD FOR WRITING
B
Correct answer
Explanation
SQL1224 occurs when the database fails to load an input file during operations. The INFILE refers to file handling operations, typically during data import or export processes.
-
DISTINCT NOT ALLOWED
-
GROUP BY index is not allowed
-
HAVING is not an aggregate expression
-
Column function is not allowed
D
Correct answer
Explanation
SQL1117 indicates that a column function (aggregate function like SUM, COUNT, AVG) was used in a context where SQL syntax rules don't permit it. Column functions require proper grouping or placement in SELECT statements.
-
FOREIGN KEY DOES NOT EXIST
-
FAILED TO CREATE FOREIGN KEY
-
FOUND VIEW COLUMN
-
INDEX ALREADY EXISTS
A
Correct answer
Explanation
SQL1145 occurs when a statement references a foreign key that doesn't exist in the database schema. This typically happens during ALTER or DROP operations when the specified foreign key constraint is not found.
-
UNEXPECTED HEADER VALUE
-
INVALID AGENT SIGNATURE
-
Both 1 and 2
-
None of these
A
Correct answer
Explanation
In this custom network protocol mapping, the SQL3018 error code represents an unexpected header value, indicating that the received packet header did not match the expected format.
-
UNKNOWN COMMAND
-
ALREADY LOGGED IN
-
NOT LOGGED IN
-
HEADER NOT FOUND
D
Correct answer
Explanation
SQL3000 is an error code indicating that a required header was not found in the communication protocol or data stream between the client and database server. This typically occurs during connection establishment when expected protocol headers are missing.
-
INVALID AGENT SIGNATURE
-
STILL LOGGED IN
-
INVALID STATEMENT ID
-
HEADER NOT FOUND
A
Correct answer
Explanation
SQL3017 represents an authentication or authorization error where the agent signature provided during connection is invalid or cannot be verified. The database system rejects connections that don't present proper credentials.
-
Failed to aggregate
-
Failed to execute DISTINCT
-
Failed to execute HAVING clause
-
Failed to execute WHERE clause
A
Correct answer
Explanation
SQL1816 indicates a failure during aggregation operations in SQL queries. This occurs when the database engine cannot successfully compute aggregate functions like SUM, COUNT, AVG, MAX, or MIN, often due to data type mismatches or grouping issues.
-
Failed to validate CASE expression
-
Failed to execute UPDATE command
-
Failed to calculate LIKE predicate pattern
-
Failed to validate column list
D
Correct answer
Explanation
SQL1724 indicates a validation failure for the column list specified in a SQL statement. This error occurs when the database cannot verify the existence, accessibility, or compatibility of columns referenced in a query.
-
FAILED TO PARSE YEAR
-
UNEXPECTED CHARACTER
-
Failed to parse duration
-
Failed to parse timestamp
C
Correct answer
Explanation
SQL1513 occurs when the database engine cannot interpret a duration specification in a query. This typically happens with interval expressions where the duration format is invalid or contains unrecognized tokens.
-
VARIABLE WAS NOT FOUND
-
POINTER OF UNKNOWN TYPE
-
RESULT IS NOT A SELECTION
-
ARRAY NOT ALLOWED IN EXECUTE IMMEDIATE
B
Correct answer
Explanation
SQL1432 indicates a pointer type error where the database system encounters a pointer of an unrecognized or unsupported type. This is a low-level error related to memory addressing or data type handling in database operations.