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

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 programming languages
  1. SetSQLSelect

  2. ChangeSQLSelect ( string statement )

  3. ChangeSQLSelect

  4. SetSQLSelect ( string statement )

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

SetSQLSelect(string statement) is the DataWindow function used to change the SQL statement programmatically. It's specifically designed to replace the SELECT statement while preserving the DataWindow's other properties, unlike the Modify function which is more general-purpose.

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 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 platforms and products
  1. It is a KeyFlex field used to store different segment values.

  2. It will store attribute values that will be used to track future requirements.

  3. knowledge Flex Field

  4. It is containing of one segment

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Oracle E-Business Suite, a Key Flexfield (KFF) is used to capture key information, such as account codes or part numbers, and consists of multiple segments that represent a structured code.

Multiple choice technology platforms and products
  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 in Oracle are specifically used to perform DML operations on views that involve multiple base tables, which normally wouldn't be directly updateable. Option A is incomplete. Option C is incorrect because read-only views cannot be modified even with triggers. Option D is incorrect - INSTEAD OF triggers have a specific purpose.

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.

Multiple choice technology databases
  1. The two statements produce identical results.

  2. The second statement returns a syntax error

  3. There is no need to specify DESC because the results are sorted in descending order by default

  4. The two statements can be made to produce identical results by adding a column alias for the salary column in the second SQL statement.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To understand these SQL statements, the user needs to know the basic syntax of the SELECT statement and the ORDER BY clause. The SELECT statement retrieves data from one or more tables, and the ORDER BY clause sorts the results in ascending or descending order based on one or more columns' values.

The first SQL statement retrieves the last_name, salary, and hire_date columns from the EMPLOYEES table and sorts the results in descending order based on the salary column's values.

The second SQL statement retrieves the last_name, salary, and hire_date columns from the EMPLOYEES table and sorts the results in descending order based on the second column, which is the salary column.

A. The two statements produce identical results. This is correct because both statements retrieve the same columns and sort the results in descending order based on the salary column's values.

B. The second statement returns a syntax error. This is incorrect because the second SQL statement is syntactically correct and will execute without errors.

C. There is no need to specify DESC because the results are sorted in descending order by default. This is incorrect because the default order is ascending, not descending. If the user wants to sort the results in descending order, they must specify DESC explicitly.

D. The two statements can be made to produce identical results by adding a column alias for the salary column in the second SQL statement. This is incorrect because adding a column alias does not affect the sorting order. The two statements already produce identical results, so there is no need to modify them.

Therefore, the answer is: A. The two statements produce identical results.

Multiple choice technology databases
  1. SELECT TO_DATE(SYSDATE, 'FMDAY, DD Month, YYYY') FROM dual;

  2. SELECT TO_CHAR(SYSDATE, 'FMDD, DY Month, 'YYYY') FROM dual;

  3. SELECT TO_CHAR(SYSDATE, 'FMDay, DD Month, YYYY') FROM dual;

  4. SELECT TO_CHAR(SYSDATE, 'FMDY, DDD Month, YYYY') FROM dual;

  5. SELECT TO_DATE(SYSDATE, 'FMDY, DDD Month, YYYY') FROM dual;

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To solve this question, the user needs to know the basic SQL functions like TO_CHAR and SYSDATE and their usage and format masks.

Option A: This option is incorrect because it uses the wrong format mask and does not give the required output format. The 'FMDAY' format mask is not correct to get the desired output format.

Option B: This option is incorrect because it uses the wrong format mask and does not give the required output format. The 'FMDD' format mask is not correct to get the desired output format.

Option C: This option is correct. It uses the correct format mask and gives the required output format. The 'FMDay' format mask gives the day of the week in the full name format and 'DD Month, YYYY' gives the date in the required format.

Option D: This option is incorrect because it uses the wrong format mask and does not give the required output format. The 'FMDY' format mask is not correct to get the desired output format.

Option E: This option is incorrect because it uses the wrong function and format mask. TO_DATE function is used to convert a string to a date, not to format the date. Additionally, 'DDD' format mask is not required to get the desired output format.

Therefore, the answer is:

The Answer is: C. SELECT TO_CHAR(SYSDATE, 'FMDay, DD Month, YYYY') FROM dual;

Multiple choice technology databases
  1. SELECT SUBSTR ('Hello',) FROM dual;

  2. SELECT INITCAP (TRIM ('Hello World',1,1) FROM dual;

  3. SELECT LOWER (SUBSTR ('Hello World',1,1) FROM dual

  4. SELECT LOWER (SUBSTR ('Hello World',2,1) FROM dual;

  5. SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual;

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

The question asks for 'ello world' from 'Hello World'. The correct approach is to remove the first character 'H' and convert the result to lowercase. Option E does exactly this: TRIM('H' FROM 'Hello World') removes 'H' from the beginning, then LOWER() converts 'ello World' to 'ello world'. The other options either don't remove the first character correctly or have syntax errors like missing parentheses.

Multiple choice technology databases
  1. INSTR returns the numeric position of a named character.

  2. NVL2 returns the first non-null expression in the expression list.

  3. DECODE translates an expression after comparing it to each search value

  4. TRIM trims the heading of trailing characters (or both) from a character string

  5. NVL compares two expressions and returns null if they are equal, or the first expression of they are not equal

  6. NULLIF compares twp expressions and returns null if they are equal, or the first expression if they are not equal

Reveal answer Fill a bubble to check yourself
A,C,D,F Correct answer