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. Downtime

  2. Stability

  3. Performance

  4. Volatility

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

Performance is the primary motivation for denormalization - reducing joins improves read speed. Volatility is equally critical - frequently changing data causes update anomalies and maintenance overhead in denormalized structures. Downtime and stability are operational concerns, not architectural considerations for denormalization.

Multiple choice technology mainframe
  1. Primary Key

  2. Check constraint

  3. Foreign Key

  4. Update trigger

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

A referential constraint maintains relationships between tables by ensuring that values in a foreign key column match existing values in the parent table's primary key. The foreign key is defined on the dependent (child) table and points to the primary key of the referenced (parent) table. Check constraints validate column values, while triggers perform actions in response to events, but neither implements referential integrity.

Multiple choice technology mainframe
  1. NEWTAB would have the same column names, attributes and referntial integrity as TAB.

  2. NEWTAB would have the same column names and attributes as TAB.

  3. NEWTAB would have the same column names, attributes, indexes and constraints as TAB.

  4. NEWTAB would have the same column names, attributes and data as TAB.

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

CREATE TABLE newtab LIKE tab copies the column definitions and their data types from tab but does not duplicate indexes, constraints, or any existing rows, so the new table has the same columns and attributes only.

Multiple choice technology mainframe
  1. ORDER BY 2,1

  2. ORDER BY 2 ASC, 1 ASC

  3. ORDER BY 1,2

  4. ORDER BY 1 ASC, 2 ASC

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

ORDER BY 1,2 sorts first by the first selected column (name) then by the second (cities) in ascending order by default; specifying ASC explicitly (1 ASC,2 ASC) does the same. Using column numbers 2,1 or 2 ASC,1 ASC would reverse the intended order.

Multiple choice technology databases
  1. each SELECT statement within the UNION has the same number of columns

  2. The columns have similar data types

  3. the columns in each SELECT statement are in same order.

  4. None

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

UNION combines results from multiple SELECT statements into one result set. SQL requires all SELECTs in a UNION to have identical column count, compatible data types in each position, and the same column order. These structural rules ensure rows can be stacked vertically.

Multiple choice technology databases
  1. True

  2. False

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

Sybase IQ's column-oriented architecture treats every column as an indexed structure by default. Unlike traditional row-based databases that require explicit index creation, Sybase IQ stores data in highly compressed, indexed column structures. This architectural design is fundamental to its performance for analytical queries.

Multiple choice technology databases
  1. LF

  2. HG

  3. HNG

  4. CMP

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

LF (Low Fast) index is optimized for columns with high cardinality like primary keys, providing efficient lookup performance. HG (High Group) is better for low-cardinality columns with many duplicates. HNG (High Non-Grouped) and CMP are not standard Sybase IQ index types for this use case.

Multiple choice technology databases
  1. True

  2. False

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

Sybase IQ uses write locking where one process writing to a table blocks other processes from updating the same table. This prevents concurrent modification conflicts. The blocking process will fail or wait depending on isolation settings.

Multiple choice technology databases
  1. Longevity

  2. Selectivity

  3. Productivity

  4. Usefulness

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

Selectivity estimates the fraction of rows matching a predicate, crucial for cost-based optimization. Usefulness indicates how effectively a search argument filters the result set. Together they guide the optimizer in choosing efficient access paths.

Multiple choice technology databases
  1. Leading column in the index is not part of the search arguments

  2. Data types are not matching while doing a join

  3. Optimizer decides that table scan is better

  4. Index name is improper

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

Indexes are ignored if the leading column is missing from search arguments, or if mismatched data types force implicit conversions. The optimizer may also bypass an index for a table scan if selectivity is low. Index names do not affect optimizer decisions.

Multiple choice technology databases
  1. True

  2. False

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

Microsoft recommends a clustered index for almost every SQL Server table because it physically orders the data, greatly improving retrieval speeds for range queries and joins. Without a clustered index, the table exists as an unordered heap, which can lead to severe data fragmentation and slower lookups.