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
-
You cannot use SSIS to import non-standard text files
-
Use a flat file connection and assign text file for the connection and get the data
-
Use a flat file connection and Transformation option of the script component. The use some code get the orderdate
-
Use fuzzy grouping and a flat file connection to get order date
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.
-
20090525
-
Error
-
2009-may-25
-
may-25-2009
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.
-
select ' ' ' || 'TCS' || ' ' ' from dual
-
select ' ' 'TCS' ' ' from dual
-
select 'TCS' from dual
-
select "TCS" from dual
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.
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.
-
True
-
False
-
There is a problem with the statement.
-
None of above
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.
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).
-
WHERE
-
HAVING
-
RESTRICT
-
GROUP BY
-
ORDER BY
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).
-
UNIQUE
-
NOT NULL
-
CHECK
-
PRIMARY KEY
-
FOREIGN KEY
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).
-
INSERT
-
UPDATE
-
SELECT
-
DESCRIBE
-
DELETE
D
Correct answer
Explanation
DESCRIBE is a command specific to SQL*Plus used to display the structure of a table or view. INSERT, UPDATE, SELECT, and DELETE are standard SQL statements.
-
VARCHAR2
-
CHAR
-
NCHAR
-
VARCHAR
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.
-
NCHAR
-
LONG
-
INTEGER
-
TIMESTAMP
B
Correct answer
Explanation
Oracle databases only allow one LONG column per table due to legacy design restrictions. This is a well-known Oracle limitation - other listed types (NCHAR, INTEGER, TIMESTAMP) can be used multiple times without restriction.
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.
D
Correct answer
Explanation
In PL/SQL, the maximum size of a NVARCHAR2 variable is 32,767 bytes, whereas the maximum size of a NVARCHAR2 column in an Oracle database table is 4,000 bytes.
-
SELECT FROM GROUP BY WHERE
-
SELECT FROM GROUP BY ROLLUP
-
SELECT GROUP BY FROM
-
SELECT WHERE FROM GROUP BY