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

Multiple choice technology programming languages
  1. Subsequent statements in the current processing blocks are executed

  2. There is an error message

  3. Program gets terminated

  4. Subsequent statements in the current processing blocks are not executed

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

When a CHECK statement condition fails outside a loop structure, the current processing block terminates and subsequent statements in that block are not executed. This is standard control flow behavior - a failed check stops execution of the current code block.

Multiple choice technology mainframe
  1. DB2 for z/OS Version 8.1

  2. DB2 for z/OS Version 9.1

  3. DB2 for Linux Version 9.1

  4. DB2 for Version 7.0

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is a site-specific question about the DB2 version used in SECOM. DB2 for z/OS Version 9.1 is the correct version for this enterprise environment. DB2 is IBM's relational database management system for mainframes.

Multiple choice technology databases
  1. Failed to validate subquery

  2. Failed to validate CASE expression

  3. Failed to validate column list

  4. Failed to validate foreign key.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

SQL1715 error specifically indicates failure to validate a subquery. This occurs when the database cannot process or verify the structure/logic of a nested query. It is distinct from CASE expression validation (B), column list validation (C), or foreign key validation (D) which have different error codes.

Multiple choice technology databases
  1. Failed to validate IN predicate

  2. Failed to validate HAVING clause

  3. Failed to validate CASE expression

  4. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

SQL1707 error indicates failure to validate the HAVING clause in a SQL query. The HAVING clause is used to filter results after GROUP BY aggregation, and this error means the database cannot validate its structure or logic. It differs from IN predicate validation (A), CASE expression validation (C), and other SQL validations.

Multiple choice technology
  1. In the master data table as an attribute

  2. In the transaction table as a new characteristic

  3. In the ODS to enhance performance

  4. In the fact table

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Frequently changing prices should be modeled as time-dependent transaction data, not static master data attributes. This preserves historical price accuracy and supports performance. The ODS (C) and fact table (D) are incorrect for this use case.

Multiple choice technology
  1. Key figures InfoObjects

  2. Characteristic InfoObjects

  3. Calculated key figures InfoObjects

  4. DIM IDs

Reveal answer Fill a bubble to check yourself
A,D Correct answer
Explanation

In data warehousing, fact tables contain key figures (metrics or measurements) and DIM IDs (foreign keys referencing dimension tables). The actual dimension attributes (Characteristics) live in dimension tables, not fact tables.

Multiple choice technology web technology
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Hibernate is indeed an Object-Relational Mapping (ORM) framework for Java that provides a bridge between object-oriented domain models and relational databases. It allows developers to work with Java objects instead of writing raw SQL queries, automatically handling the translation between objects and database records.

Multiple choice technology databases
  1. The indexed column is declared as NOT NULL

  2. The indexed columns are used in the FROM clause

  3. The indexed columns are part of an expression

  4. The indexed column contains a wide range of values

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To answer this question, the user needs to know what an index is and how it works.

An index is a data structure that improves the speed of data retrieval operations on a database table. It does this by providing a quick lookup mechanism for finding rows that match certain column values in the table. Indexes are most useful when searching large tables for a specific value or set of values.

Now, let's go through each option and explain why it is right or wrong:

A. The indexed column is declared as NOT NULL: This option is not necessarily the most useful scenario for an index. Declaring a column as NOT NULL simply means that the column cannot contain NULL values. While this may improve data integrity, it does not necessarily make an index more useful.

B. The indexed columns are used in the FROM clause: This option is not necessarily the most useful scenario for an index, either. Using indexed columns in the FROM clause can help improve query performance by allowing the database to retrieve only the necessary rows. However, it does not necessarily make the index more useful than other scenarios.

C. The indexed columns are part of an expression: This option can be useful for an index. When indexed columns are part of an expression, the database can still use the index to search for values that match the expression. This can help improve query performance.

D. The indexed column contains a wide range of values: This option is the most useful scenario for an index. When a column contains a wide range of values, it can be difficult for the database to search through all the values to find the ones that match a specific criteria. However, if the column is indexed, the database can use the index to quickly find the values that match the criteria, which can greatly improve query performance.

Therefore, the correct answer is:

The Answer is: D

Multiple choice technology databases
  1. ORDER BY SALARY > 5000

  2. GROUP BY SALARY > 5000

  3. HAVING SALARY > 5000

  4. WHERE SALARY > 5000

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To solve this question, the user needs to know the basic syntax of a SELECT statement in SQL, including the purpose of each clause.

The WHERE clause is used to filter the rows returned by a query based on specified conditions. In this case, we want to limit the display to only those employees whose salary is greater than 5000. Therefore, the correct answer is:

The Answer is: D. WHERE SALARY > 5000

Option A, ORDER BY SALARY > 5000 is incorrect because the ORDER BY clause is used to sort the rows returned by a query in ascending or descending order based on a specified column. It is not used to filter rows based on specific conditions.

Option B, GROUP BY SALARY > 5000 is incorrect because the GROUP BY clause is used to group the rows returned by a query based on one or more columns. It is not used to filter rows based on specific conditions.

Option C, HAVING SALARY > 5000 is incorrect because the HAVING clause is used to filter the rows returned by a query based on conditions that involve aggregate functions, such as SUM, COUNT, AVG, MAX, and MIN. It is not used to filter rows based on specific conditions.

Multiple choice technology databases
  1. To simplify the process of creating new users using the CREATE USER xxx IDENTIFIED by yyy statement

  2. To grant a group of related privileges to a user

  3. When the number of people using the database is very high

  4. To simplify the process of granting and revoking privileges

Reveal answer Fill a bubble to check yourself
C,D Correct answer
Explanation

Roles simplify privilege management by grouping related privileges together, making it easier to grant and revoke permissions for multiple users. This is especially valuable when many users need similar access patterns.

Multiple choice technology databases
  1. Use the DESCRIBE command in the EMP_DEPT VU view

  2. Use the DEFINE VIEW command on the EMP_DEPT VU view

  3. Use the DESCRIBE VIEW command on the EMP_DEPT VU view

  4. Query the USER_VIEWS data dictionary view to search for the EMP_DEPT_VU view

  5. Query the USER_SOURCE data dictionary view to search for the EMP_DEPT_VU view

  6. Query the USER_OBJECTS data dictionary view to search for the EMP_DEPT_VU view

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In Oracle, view definitions are stored in the USER_VIEWS data dictionary view, with the TEXT column containing the SELECT statement. This is the standard way to retrieve view definitions.

Multiple choice technology databases
  1. Constraints provide data independence

  2. Constraints make complex queries easy

  3. Constraints enforce rules at the view level

  4. Constraints enforce rules at the table level

  5. Constraints prevent the deletion of a table if there are dependencies

  6. Constraints prevent the deletion of an index if there are dependencies

Reveal answer Fill a bubble to check yourself
C,D,E Correct answer