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

Multiple choice technology databases
  1. 3

  2. 6

  3. 5

  4. 4

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

INSTR('TCS_SQL','S',4) searches for 'S' starting from position 4 in 'TCS_SQL'. Positions 1-3 are 'T', 'C', 'S' (the first S). From position 4, the string is '_SQL', where 'S' is at position 5 of the original string (second S in the string).

Multiple choice technology programming languages
  1. WHERE

  2. HAVING

  3. RESTRICT

  4. GROUP BY

  5. ORDER BY

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

To answer this question, the user needs to understand the purpose of each of the SQL clauses listed and how they are used in a query.

  • WHERE: This clause is used to filter rows of data based on a specified condition or set of conditions. It is used to limit which rows are selected from a table.

  • HAVING: This clause is used to filter the results of an aggregate function applied to a group of rows. It is used to limit which groups are displayed based on a specified condition or set of conditions.

  • RESTRICT: There is no such SQL clause as RESTRICT.

  • GROUP BY: This clause is used to group rows of data based on one or more columns. It is used in conjunction with aggregate functions to calculate results for each group of data.

  • ORDER BY: This clause is used to sort the results of a query by one or more columns in ascending or descending order.

Based on the above information, the correct answer to the question is:

The Answer is: B. HAVING.

The HAVING clause is used to filter the results of an aggregate function applied to a group of rows. It is used to limit which groups are displayed based on a specified condition or set of conditions. Therefore, it can be used to exclude group results that don't meet the specified condition(s).

Multiple choice technology programming languages
  1. UNIQUE

  2. NOT NULL

  3. CHECK

  4. PRIMARY KEY

  5. FOREIGN KEY

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

NOT NULL is strictly a column-level constraint that prevents null values in a specific column and cannot be defined at the table level. UNIQUE, CHECK, PRIMARY KEY, and FOREIGN KEY can all be defined at either column level (for single columns) or table level (for multiple columns or composite constraints).

Multiple choice technology databases
  1. VARCHAR2

  2. CHAR

  3. NCHAR

  4. VARCHAR

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

VARCHAR is the ANSI SQL standard character type, while VARCHAR2 and CHAR are Oracle-specific. NCHAR is Oracle's Unicode character type. VARCHAR stands out as the odd one because it's the standard SQL type rather than Oracle's proprietary extension.

Multiple choice technology databases
  1. NCHAR

  2. DATE

  3. VARCHAR2

  4. BLOB

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

CHAR is for fixed-length character strings. NCHAR and VARCHAR2 are also character types compatible with CHAR. DATE is compatible in some contexts (implicit conversion). BLOB is for binary data and has no compatibility with character types like CHAR.