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

Multiple choice technology databases
  1. 1

  2. error

  3. null

  4. 0

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. 18

  2. 19

  3. 21

  4. none of the above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. 1x4y6789

  2. 1xy456789

  3. 1xy46789

  4. error

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology web technology
  1. Positioned

  2. Searched

  3. Embedded

  4. Dynamic

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. List of Values with validation.

  2. Storing varchar Data.

  3. Storing number Data.

  4. List of Value.

Reveal answer Fill a bubble to check yourself
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').

Multiple choice technology databases
  1. Explicity fired.

  2. Not taking space in database.

  3. Only DML triggers are there.

  4. Trigger timing is mandatory.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. To insert in a view.

  2. To insert in a view which is created with more than one table.

  3. To insert into read only view.

  4. None.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. Character

  2. Date

  3. Integer

  4. RAW

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology platforms and products
  1. Explicity fired.

  2. Not taking space in database.

  3. Only DML triggers are there.

  4. Trigger timing is mandatory.

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology databases
  1. The underlying tables must have data

  2. You need SELECT privileges on the view

  3. The underlying tables must be in the same schema

  4. You need SELECT privileges only on the underlying tables

Reveal answer Fill a bubble to check yourself
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.