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
D
Correct answer
Explanation
The INSTR function searches for a substring within a string. With start_position=-1, it searches backwards from the end of the string. The occurrence parameter specifies which occurrence to find. Since 'd' exists in 'oracle' at position 15, the function should return 15. However, if the function returns 0, it could indicate either the substring was not found or there's a specific behavior with negative start positions that depends on Oracle version. The correct answer depends on actual Oracle behavior.
-
18
-
19
-
21
-
none of the above
A
Correct answer
Explanation
The SQL query uses LENGTH() function on the string 'This is Ram''s book'. The double quote ('') in SQL represents a single literal quote character. Counting: T-h-i-s- -i-s- -R-a-m-'-s- -b-o-o-k = 18 characters. The LENGTH function counts all characters including spaces and the apostrophe.
-
1x4y6789
-
1xy456789
-
1xy46789
-
error
C
Correct answer
Explanation
The Oracle TRANSLATE function replaces characters in a string. It maps '2' to 'x' and '3' to 'y'. Because '5' has no corresponding character in the replacement string 'xy', it is removed entirely. Thus, '123456789' becomes '1xy46789'.
-
1x4y6789
-
1xy456789
-
1xy46789
-
error
C
Correct answer
Explanation
TRANSLATE('source', 'from', 'to') replaces each character in 'from' with corresponding character in 'to'. Here: '235' maps to 'xy' (2→x, 3→nothing, 5→y). So '123456789' becomes '1xy46789' - 2 becomes x, 3 is removed, 5 becomes y. The key is understanding that 3 maps to empty string.
B
Correct answer
Explanation
ERROR is NOT an internal SAS variable used to mark errors within a dataset. The correct automatic variable is ERROR (with one underscore on each side), which is set to 1 when an error occurs during DATA step execution. However, the question asks about it being used to mark errors 'within a dataset', which is misleading - it marks DATA step execution errors, not dataset-specific errors.
-
Primary key
-
Unique key
-
Foreign key
-
Composite key
C
Correct answer
Explanation
To implement a referential integrity constraint between two tables, a foreign key is defined on the child table, pointing to the primary key or unique key of the parent table.
-
Positioned
-
Searched
-
Embedded
-
Dynamic
A
Correct answer
Explanation
A positioned delete operation deletes the row at the current cursor position. The 'WHERE CURRENT OF csr1' clause indicates this is a positioned delete - it removes the row currently pointed to by cursor csr1. A searched delete uses a WHERE clause with conditions, an embedded delete is SQL within host code, and dynamic delete is constructed at runtime.
-
List of Values with validation.
-
Storing varchar Data.
-
Storing number Data.
-
List of Value.
A
Correct answer
Explanation
List of Values (LOV) with validation is a common UI component that restricts user input to predefined valid values. Option A correctly identifies this concept. Option B and C refer to generic data storage, not LOVs. Option D is grammatically incorrect ('List of Value' should be 'Values').
-
Explicity fired.
-
Not taking space in database.
-
Only DML triggers are there.
-
Trigger timing is mandatory.
D
Correct answer
Explanation
In database triggers (Oracle/PLSQL), trigger timing (BEFORE/AFTER/INSTEAD OF) is a mandatory clause. Every trigger must specify when it fires relative to the DML event. Options A, B, and C are incorrect - triggers can be implicit/automatic, they occupy space in database, and DML/DDL triggers both exist.
-
To insert in a view.
-
To insert in a view which is created with more than one table.
-
To insert into read only view.
-
None.
B
Correct answer
Explanation
INSTEAD OF triggers are specifically designed for complex views that join multiple tables, where direct DML is not allowed. The trigger intercepts the INSERT and translates it to operations on the underlying base tables. Option B correctly identifies this use case. Options A and C don't explain why INSTEAD OF is needed specifically.
-
Character
-
Date
-
Integer
-
RAW
D
Correct answer
Explanation
RAW datatype in Informatica represents binary data and cannot be implicitly or explicitly converted to other datatypes like string, number, or date. RAW data must be handled as binary - attempting conversion will cause errors. Character, Date, and Integer can all be converted to each other using appropriate conversion functions like TO_CHAR, TO_DATE, or TO_INTEGER.
-
Explicity fired.
-
Not taking space in database.
-
Only DML triggers are there.
-
Trigger timing is mandatory.
D
Correct answer
Explanation
Trigger timing (BEFORE, AFTER, INSTEAD OF) is a mandatory attribute when defining triggers in Oracle. Option A is incorrect because triggers are implicitly fired by events. Option B is incorrect - triggers do occupy space in the database. Option C is incorrect - there are also DDL and system event triggers.
-
IN,OUT
-
OUT,OUT
-
IN ,IN
-
OUT,IN
B
Correct answer
Explanation
In Oracle Apps concurrent programs, errbuf and retcode are both OUT parameters - errbuf returns error messages and retcode returns completion status codes. Options A, C, and D incorrectly specify IN parameters.
-
The underlying tables must have data
-
You need SELECT privileges on the view
-
The underlying tables must be in the same schema
-
You need SELECT privileges only on the underlying tables
B
Correct answer
Explanation
To query a view, a user must have the SELECT privilege on the view itself. They do not necessarily need direct privileges on the underlying base tables, as the view owner's privileges grant access.