Computer Knowledge

Database and SQL

3,929 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 programming languages
  1. True

  2. False

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

Most database systems do not allow calling stored functions within table constraints like CHECK constraints. This is because constraints must be deterministic and schema-bound - they cannot rely on user-defined functions that might change or have side effects. Constraints are validated during query optimization and execution planning, where stored function calls would introduce complexity and potential performance issues.

Multiple choice technology programming languages
  1. True

  2. False

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

INSTEAD OF triggers can be defined on views in database systems like SQL Server and Oracle. These triggers fire instead of the DML operation (INSERT, UPDATE, DELETE) that would otherwise be performed on the view. This allows you to implement custom logic for updating views that would otherwise be non-updatable because they join multiple tables or contain computed columns.

Multiple choice technology databases
  1. to_char

  2. max

  3. cube

  4. rollup

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

To answer this question, the user needs to have knowledge of SQL functions.

A. to_char: This function is used to convert a number or date to a string. It cannot operate on any datatype.

B. max: This function returns the maximum value in a set of values. It can operate on any datatype.

C. cube: This function is used to generate a result set that represents the subtotals and grand totals of the selected columns. It cannot operate on any datatype.

D. rollup: This function is used to generate a result set that represents the subtotals of the selected columns. It cannot operate on any datatype.

Therefore, the correct answer is:

The Answer is: B. max

Multiple choice technology databases
  1. Primary key access

  2. Full table scan

  3. Access via unique index

  4. Table access by ROWID

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

ROWID is Oracle's internal physical address for each row. Access by ROWID is the fastest method because it's a direct physical lookup, avoiding index traversal or full scans. Primary key and unique index access are fast but require index navigation.

Multiple choice technology
  1. You cannot use SSIS to import non-standard text files

  2. Use a flat file connection and assign text file for the connection and get the data

  3. Use a flat file connection and Transformation option of the script component. The use some code get the orderdate

  4. Use fuzzy grouping and a flat file connection to get order date

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

The Script Component in transformation mode allows custom C# or VB.NET code to parse each row and handle variable structures (like missing orderdate fields). Standard flat file connections require uniform schemas across all rows, and fuzzy grouping is for data matching, not structural variations.

Multiple choice technology
  1. You cannot use SSIS to import non-standard text files

  2. Use a flat file connection and assign text file for the connection and get the data

  3. Use a flat file connection and Transformation option of the script component. The use some code get the orderdate

  4. Use fuzzy grouping and a flat file connection to get order date

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

When importing text files with non-standard or missing fields in SSIS, the Script Component transformation provides the most flexibility. You can write custom code to handle variable column counts, conditional logic for missing fields like orderdate, and data validation. Standard flat file connections require consistent structure, and fuzzy grouping is designed for data matching, not handling missing columns.

Multiple choice technology databases
  1. 20090525

  2. Error

  3. 2009-may-25

  4. may-25-2009

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

The TO_DATE function expects the input string to match the specified format. '2009-may-25' contains a textual month abbreviation, but the format 'yyyymmdd' expects digits. The correct format would be 'yyyy-mon-dd' or similar, or the input should be '20090525'. The mismatch between textual month and numeric format causes an error.

Multiple choice technology databases
  1. select ' ' ' || 'TCS' || ' ' ' from dual

  2. select ' ' 'TCS' ' ' from dual

  3. select 'TCS' from dual

  4. select "TCS" from dual

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

In Oracle SQL, to include a single quote in a string literal, you escape it by doubling it. The string ' ' 'TCS' ' ' actually parses as: quote-space-quote (space), then 'TCS', then quote-space-quote (space). The doubled quotes represent literal single quote characters. Option B correctly uses this escaping.

Multiple choice technology databases
  1. No data found

  2. Error

  3. 1

  4. 0

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

COUNT() is an aggregate function that returns the total number of rows in a table, including null values. When a table is empty (no rows), COUNT() returns 0, not an error or 'No data found' message. This is fundamental SQL behavior.

Multiple choice technology testing
  1. True

  2. False

  3. There is a problem with the statement.

  4. None of above

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

QTP maintains synchronization between Expert View (VBScript code) and Keyword View (table format). Every object and method statement in Expert View has a corresponding row in Keyword View. This bidirectional mapping allows switching between views without losing test logic.