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 enterprise content management
  1. Having a single SQL query with FACT A, FACT B and Conf D.

  2. Have a individual query between FACT A & Conf D, and a individual query between FACT B & Conf D.

  3. Have three individual queries, one for each table.

  4. A and B

  5. All of the above

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

With conformed dimensions, the best practice is to query each fact table separately against the shared dimension (individual queries). A single query joining both facts directly would create a snowflake pattern that can cause performance issues and incorrect results due to fact table explosion (cartesian product of fact rows).

Multiple choice technology databases
  1. col$
  2. aud$
  3. row$
  4. none

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

AUD$ is the audit trail table in Oracle that can be modified, typically for maintenance purposes like truncating old audit records. Other SYS tables like COL$ and ROW$ are data dictionary tables that should never be directly modified.

Multiple choice technology programming languages
  1. Names are case sensitive.

  2. Names must not be oracle server reserve word.

  3. Table names and column names need not be start with a letter.

  4. We cannot use a column alias in a WHERE clause

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

In Oracle SQL, table/column names cannot be reserved words (like SELECT, FROM, etc.) without quoting. Column aliases (defined in SELECT clause) cannot be used in WHERE clause because WHERE is processed before SELECT. Names are case-insensitive and must start with a letter.

Multiple choice technology programming languages
  1. Select

  2. Insert

  3. Update

  4. Create

  5. Delete

  6. Alter

Reveal answer Fill a bubble to check yourself
A,B,C,E Correct answer
Explanation

DML (Data Manipulation Language) commands operate on existing data within database objects. SELECT retrieves data, INSERT adds new rows, UPDATE modifies existing data, and DELETE removes rows. CREATE and ALTER are DDL (Data Definition Language) commands that define or modify database structures, not manipulate data.

Multiple choice technology programming languages
  1. The column contain wide range of values.

  2. The column contain large number of Null values.

  3. The table is large.

  4. Columns which are not frequently used.

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

Indexes are beneficial when columns contain wide range of values (high cardinality), when tables are large (performance impact is significant), and when columns contain many NULL values (indexes can efficiently skip NULLs). Columns that are infrequently used don't benefit from indexing as the query performance gain wouldn't justify the storage and maintenance overhead.

Multiple choice technology programming languages
  1. EXFMT

  2. UPDAT

  3. EXCPT

  4. WRITE

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

EXCPT (Exception Output) in RPG is specifically designed to update only selected fields on a record when certain conditions are met, rather than writing entire records. EXFMT writes formatted display records, UPDAT is not a valid RPG operation code, and WRITE creates new records rather than updating existing ones.

Multiple choice technology databases
  1. When an entire index is scanned to locate rows we call it as index scan

  2. When only part of the index is scanned to locate rows we call it as index scan

  3. When all the rows are scanned we call it as index scan

  4. None of the above

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

An index scan occurs when DB2 accesses and searches the index structure itself to locate the requested rows, rather than scanning the entire tablespace.

Multiple choice technology databases
  1. Complex Key

  2. Secondary Key

  3. Composite Key

  4. Foreign Key

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

A composite key is a key that consists of two or more columns used together to uniquely identify a row in a table. Unlike a simple key that uses a single column, composite keys combine multiple columns to ensure uniqueness when no single column can uniquely identify records.

Multiple choice technology databases
  1. FOR HOLD

  2. FOR UPDATE

  3. FOR FETCH

  4. WITH HOLD

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

The WITH HOLD option in cursor declaration maintains the cursor position across transaction boundaries. When a transaction commits, a WITH HOLD cursor remains open and positioned, allowing continued fetching without repositioning. FOR FETCH is not a valid DB2 cursor option.

Multiple choice technology mainframe
  1. select, update, create, insert

  2. select, update, alter, modify

  3. alter, update, create, insert

  4. select, update, delete, insert

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

The four DML (Data Manipulation Language) statements in DB2 are SELECT (retrieve), UPDATE (modify existing), DELETE (remove), and INSERT (add new). These are the core statements for modifying table data.