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

Multiple choice technology databases
  1. Not Null

  2. Check

  3. Unique key

  4. All of above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. It process tuples one by one

  2. It can be used in PLSQL

  3. It can use SET operators

  4. None of above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology testing
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. SQL System Error

  2. SQL Data base error

  3. SQL numeric error

  4. None of the these

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Database error

  2. MYSYSCONF not found

  3. ORDER BY column not in result table

  4. not valid for naming convention

Reveal answer Fill a bubble to check yourself
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).

Multiple choice technology databases
  1. interger not found

  2. Numeric not allowed

  3. Name &1 not allowed.

  4. ORDER BY column not in result table

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Constraint or Key not found

  2. Foreign key references non-existent table

  3. Before Delete trigger failed

  4. Row to DELETE not found

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Trigger not found

  2. Trigger name not unique

  3. Trigger with same EVENT, TIME, and ORDER already defined

  4. Fatal Connection error

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Numeric expected

  2. Integer expected

  3. Column Constraint expected

  4. Invalid table name

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Fatal error occurred

  2. %THRESHOLD Violation

  3. Privilege Violation

  4. Access violation

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Unknown or non-unique User or Role

  2. Cannot INSERT/UPDATE/DELETE on a read only table

  3. Row to DELETE not found

  4. Operation Disallowed by Operation Table

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. After Delete trigger failed

  2. Before Delete trigger failed

  3. Before Update trigger failed

  4. Before Insert trigger failed

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Multi-Line Field not valid in ORDER BY clause

  2. Multi-Line Field must be the Left operand of the Comparison

  3. Multi-Line Field only valid for LIKE, Contains ([), or NULL Comparison

  4. None of these

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. Duplicate cursor name

  2. Unable to receive server message

  3. Invalid Stored Procedure Name

  4. None of these

Reveal answer Fill a bubble to check yourself
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.