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
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.
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.
A
Correct answer
Explanation
In most database systems (like Oracle), normal B-tree indexes generally do not store entries where all columns are NULL. However, clustered indexes (or index-organized tables) and certain specific index types can handle NULL keys depending on the RDBMS implementation.
-
By value
-
By reference
-
By type
-
none of the above
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
-
Primary key access
-
Full table scan
-
Access via unique index
-
Table access by ROWID
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.
-
DROP
-
DELETE
-
REMOVE
-
TRUNCATE
D
Correct answer
Explanation
TRUNCATE is a DDL command that deallocates data pages without logging individual row deletions, so it doesn't write to rollback segments. DELETE is a DML operation that logs each deletion for rollback. DROP removes the entire table structure, not just its data.
-
By value
-
By reference
-
By type
-
none of the above
-
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
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.
-
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.