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 mainframe
  1. True

  2. False

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

SEARCH ALL performs a binary search in COBOL tables. For predictable results, the table must be defined with ASCENDING or DESCENDING KEY, and the key must uniquely identify each table entry. Without these conditions, binary search behavior is undefined.

Multiple choice technology databases
  1. Selection

  2. Projection

  3. Joining

  4. None of these

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

The SELECT statement in SQL supports three fundamental capabilities: Selection (filtering rows with WHERE), Projection (choosing columns), and Joining (combining data from multiple tables). These are the core operations that make SELECT versatile. Option D is incorrect because all three listed capabilities are valid and fundamental to SQL queries.

Multiple choice technology databases
  1. N-2

  2. N

  3. N-1

  4. None of these

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

To join n tables together, you need a minimum of n-1 join conditions. Each join condition links two tables together, creating a chain. For example, joining 3 tables requires 2 join conditions (Table1 join Table2, Table2 join Table3). Option A (N-2) is insufficient and Option B (N) would over-join. Option D is incorrect because the formula is precisely n-1.

Multiple choice technology databases
  1. simple joins

  2. outer joins

  3. inner joins

  4. inner and outer joins

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

Equijoins, which join tables based on equality of column values, are also referred to as simple joins or inner joins. They return only matching rows from both tables. Option B is incorrect because outer joins return all rows from one or both tables, not just matches. Option D is wrong because equijoins are specifically inner joins, not outer joins.

Multiple choice technology web technology
  1. You cannot use the WHERE clause to restrict groups.

  2. You cannot use the HAVING clause to restrict groups

  3. You cannot use group functions in the WHERE clause

  4. None of these

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

In SQL, group functions (like SUM or AVG) cannot be evaluated in the WHERE clause, and the WHERE clause itself cannot filter grouped results. The HAVING clause must be used instead, making both selected options correct descriptions of illegal queries.

Multiple choice technology databases
  1. 1

  2. 2

  3. 3

  4. 0

  5. 4

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

The query SELECT address1||','||address2||','||address2 creates only 1 column. The || operator concatenates strings, and the expression address1||','||address2||','||address2 concatenates these fields into a single column named 'Adress'. Even though multiple address fields are used, they are combined into one output column.

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 address of a row in the database, representing its exact disk location. Accessing by ROWID is the fastest method because it bypasses all index lookups and goes directly to the data block. Primary key access and unique index access require first traversing the index structure to find the ROWID, then accessing the row. Full table scan is the slowest as it reads every row in the table.

Multiple choice technology databases
  1. Column

  2. 1966_Invoices

  3. Catch_#22

  4. #Invoices

  5. None of the above

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

In Oracle, standard unquoted identifiers must begin with a letter (A-Z) and can contain only letters, digits, and underscores. Option C is the only valid identifier that follows these rules. Option A uses a reserved word (though it would work if quoted). Option B starts with a digit which is invalid. Option D starts with # which is not allowed in unquoted identifiers. E is incorrect since C is valid.

Multiple choice technology databases
  1. select * from EMP where nvl(EMPNO, '00000') = '59384';

  2. select * from EMP where EMPNO = '59384';

  3. select EMPNO, LASTNAME from EMP where EMPNO = '59384';

  4. select 1 from EMP where EMPNO = '59834';

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

When a column is wrapped in a function like NVL(), the Oracle optimizer cannot use the index on that column because the function modifies the column value before comparison. For options B, C, and D, EMPNO is compared directly to a literal value, allowing index access. Option A applies NVL() to EMPNO first, making the index unusable and forcing a full table scan. This is a common performance anti-pattern.