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 testing
  1. Getlinecount

  2. count

  3. Getrowcount

  4. Getcount

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

Getrowcount is the standard method to retrieve the number of rows in a table object in QTP. Getlinecount typically refers to line counting, count is a generic term, and Getcount is not the standard QTP method for row enumeration.

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

Applying the NVL function to the indexed column EMPNO prevents the database query optimizer from using the standard index, forcing a full table scan. In contrast, the other queries query EMPNO directly without modifying the column with a function, allowing successful index usage.

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 access is the fastest method because Oracle uses the row's physical disk location directly, eliminating the need to traverse index structures or scan multiple rows. Primary key and unique index access require additional index lookups, while full table scans read every row.

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 it starts with a letter and contains only allowed characters (letters, numbers, underscore, and #). 1966_Invoices is invalid (starts with number), #Invoices is invalid (starts with special character), and Column may be a reserved word depending on the database system.

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 deletes all rows from a table and bypasses the rollback segments (undo logs), making it faster and non-transactional. DELETE is DML and writes to rollback segments, whereas DROP removes the entire table structure, and CASCADE is a constraint modifier.

Multiple choice technology databases
  1. 5

  2. 4

  3. 3

  4. There is no such criteria

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

To join N tables without creating a Cartesian product, a minimum of N-1 join conditions are required. For a four-table join, this means at least three specific conditions must be present in the WHERE (or ON) clause to properly relate all tables.

Multiple choice technology
  1. Sql Query

  2. Filters

  3. Aggregate Function

  4. By validate Report

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

Testing reports in Cognos requires validation to verify data accuracy, filter logic, and formatting. The 'Validate Report' function checks the report definition, verifies calculations, and ensures the report will execute correctly before actual execution.

Multiple choice technology
  1. 12

  2. 13

  3. 15

  4. 11

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

A single table can have a maximum of 12 triggers: 3 triggers (INSERT, UPDATE, DELETE) × 2 timing options (BEFORE, AFTER) × 2 levels (statement-level, row-level). This provides comprehensive automation for data integrity and business rule enforcement at different execution stages.

Multiple choice technology databases
  1. INSERT INTO r4r_team (id, username, exp) VALUES (1, ‘r4r01’, ‘2’);

  2. INSERT INTO r4r_team VALUES (1, ‘r4r01’, ‘2’);

  3. INSERT INTO r4r_team (id, username, exp) VALUE (1, ‘r4r01’, ‘2’);

  4. INSERT INTO table r4r_team (id, username, exp) VALUE (1, ‘r4r01’, ‘2’);

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

Option A uses the correct SQL INSERT syntax with explicit column names and VALUES keyword. Option B is risky (relies on column order). Option C incorrectly uses VALUE instead of VALUES. Option D incorrectly uses 'table' keyword.

Multiple choice technology databases
  1. True

  2. False

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

TRUNCATE is faster than DELETE because TRUNCATE deallocates data pages without logging individual row deletions. DELETE logs each row deletion, making it slower for large tables. TRUNCATE is a DDL operation, while DELETE is DML.