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 packaged enterprise solutions
  1. Indexes are only used in special cases

  2. Indexes are used to make table storage more efficient

  3. Indexes rarely make a difference in SQL performance

  4. Indexes exist solely to improve query speed

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

Indexes are database structures created specifically to accelerate data retrieval operations. They exist solely to improve query performance by providing fast access paths to data, at the cost of additional storage and write overhead. Indexes are widely used and frequently significantly impact performance.

Multiple choice technology packaged enterprise solutions
  1. View

  2. Index

  3. Synonym

  4. Sequence

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

A synonym provides an alternative name for a database object like a table, allowing you to reference it without changing the actual table name. Views are virtual tables derived from queries, not simple aliases. Indexes improve query performance and sequences generate numeric values.

Multiple choice technology packaged enterprise solutions
  1. Column Constraint

  2. Table Constraint

  3. Both A. and B

  4. None of the Above

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

SQL allows defining constraints at both column level (like NOT NULL or CHECK on a single column) and table level (like PRIMARY KEY, FOREIGN KEY, or UNIQUE that may involve multiple columns). Column constraints apply to individual columns, while table constraints can span multiple columns and enforce relationships.

Multiple choice technology programming languages
  1. True

  2. False

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

TRUNCATE is faster than DELETE because it simply deallocates data pages without logging individual row deletions. DELETE logs each row deletion for rollback capability, making it slower. TRUNCATE is a DDL operation that resets the table, while DELETE is a DML operation that removes rows one by one.

Multiple choice technology programming languages
  1. DDL

  2. DML

  3. DCL

  4. None

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

GRANT and REVOKE are Data Control Language (DCL) commands used to manage database access permissions. DDL (Data Definition Language) defines structures, DML (Data Manipulation Language) manipulates data, and DCL controls access and permissions.

Multiple choice technology programming languages
  1. True

  2. False

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

In Oracle, tables can have a large but finite number of indexes - up to the limit on the number of segments per table, which is determined by the database configuration. While the limit is high (unlimited in practical scenarios), technically it's not unlimited. The question uses 'unlimited' in a practical sense.

Multiple choice technology databases
  1. Column

  2. 1966_Invoices

  3. Catch_#22

  4. #Invoices

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

Catch_#22 is valid because SQL identifiers can contain letters, numbers, underscores, and certain special characters like hash when properly quoted. Column is a reserved word in some databases, 1966_Invoices starts with a number (problematic in some SQL dialects), and #Invoices starts with a special character.

Multiple choice technology databases
  1. Drop

  2. Delete

  3. Cascade

  4. Truncate

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

TRUNCATE is a DDL command that quickly removes all rows by resetting the table without logging individual row deletions to the rollback segment. DELETE is DML that logs each deletion, DROP removes the entire table structure, and CASCADE is a constraint option for related deletions.

Multiple choice technology databases
  1. Primary key access

  2. Access via unique index

  3. Table access by ROWID

  4. Full table scan

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

ROWID is the physical disk address of a row, so accessing by ROWID is the fastest method - Oracle goes directly to the exact location. Primary key and unique index require traversing an index structure first, and full table scan reads every row in the table.