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
-
Only varrays must start with the subscript 1.
-
Only varrays can be used as column types in database tables.
-
Both associative arrays and varrays must start with the subscript 1.
-
Both associative arrays and varrays can be used as column types in database tables.
A,B
Correct answer
Explanation
Varrays must start with subscript 1 and can be stored as table columns. Associative arrays have flexible indexing (including negative or string keys) and cannot be column types: they exist only in PL/SQL memory.
-
function index
-
B tree
-
Bitmap
-
Primary key
C
Correct answer
Explanation
Bitmap indexes are highly efficient for columns with low cardinality (high redundancy/few unique values) because they store bitmaps representing row existence. B-tree indexes are better suited for high-cardinality columns.
-
catproc.sql
-
utlchain.sql
-
catchain.sql
-
utlproc.sql
B
Correct answer
Explanation
In Oracle databases, the utlchain.sql script creates the CHAINED_ROWS table, which stores information about chained and migrated rows. This table is used with the ANALYZE command to identify rows that are chained or migrated across multiple blocks, helping optimize database performance.
-
pr4_base
-
pc_work
-
pc_other
-
none of the above
A
Correct answer
Explanation
In Pega, work classes within a class group typically map to the class group table, which defaults to pc_work. However, unless explicitly mapped otherwise, standard behavior for concrete classes not designated as part of a work pool is to fall back to the default pr4_base table.
C
Correct answer
Explanation
MONTHS_BETWEEN calculates the difference in months between two dates. Between January 1st and February 2nd, 1995, there is approximately 1 month. The function returns 1 because the dates are in consecutive months.
-
06-JUN-1994
-
07-JUL-1994
-
06-JUL-1994
-
06-JUN-1995
B
Correct answer
Explanation
ADD_MONTHS adds a specified number of months to a date. Starting from June 7, 1994 and adding 1 month gives July 7, 1994. The TO_CHAR then formats it as '07-JUL-1994'.
A
Correct answer
Explanation
The SQRT function in SQL calculates the square root of a numeric value. The square root of 25 is 5. Since DUAL is a dummy table in Oracle database, selecting SQRT(25) from it yields a single row containing the value 5.
-
Yes
-
no
-
look up is not for filtering so it throws error
-
when performing look up we need to write a stored procedure
A
Correct answer
Explanation
Lookup transformations can effectively filter records by using the lookup condition - records that match the condition are returned, while non-matching records can be dropped or processed differently. This is a common filtering technique in mappings.
-
%ROWTYPE
-
%TYPE
-
AS_COLUMN
-
None of the above
B
Correct answer
Explanation
The %TYPE attribute in PL/SQL declares a variable with the same data type as a specified column in a table. %ROWTYPE declares a record type matching an entire row. AS_COLUMN doesn't exist in PL/SQL. %TYPE is useful for maintaining type compatibility without hardcoding specific types.
B
Correct answer
Explanation
The statement claims SQL has NO error handling facility, which is False. SQL DOES have programmed error handling: PL/SQL uses EXCEPTION blocks, T-SQL uses TRY/CATCH, MySQL uses DECLARE handlers. Modern SQL implementations support robust error handling mechanisms for data manipulation errors.
-
DELCARE and BEGIN
-
DECALRE and EXCEPTION
-
EXCEPTION and END
-
BEGIN and END
B
Correct answer
Explanation
In a PL/SQL block, only BEGIN and END are mandatory. The DECLARE section (for declarations) and EXCEPTION section (for error handling) are both optional components that can be omitted if not needed.
B
Correct answer
Explanation
ROLLBACK does close a transaction by undoing all changes made since the last COMMIT. The statement claims ROLLBACK cannot close a transaction, which is incorrect - therefore the answer is False.
-
A stored procedure on the server.
-
A block of code in a PL/SQL library.
-
A standalone procedure on the client machine.
-
A block of code in the body of the program unit ORDERTOTAL.
-
A local subprogram defined within the program unit ORDERTOTAL.
E
Correct answer
Explanation
A local subprogram within ORDERTOTAL is ideal because it's scoped only to that unit (avoiding global scope pollution) while being reusable from multiple places within ORDERTOTAL. Stored procedures or standalone code would be overly broad for this requirement.
-
Some DML,PL/SQL statements
-
All DML,PL/SQL statements
-
Only PL/SQL statements
-
None of the Above
B
Correct answer
Explanation
Oracle automatically declares implicit cursors for ALL DML statements and PL/SQL blocks. Every INSERT, UPDATE, DELETE, and SELECT operation that processes rows uses an implicit cursor, not just some of them.