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 databases
  1. Primary key access

  2. Access via unique index

  3. Table access by ROWID

  4. Full table scan

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

Access by ROWID is fastest because ROWID is the physical address of the row in the data file. Oracle can go directly to that location without traversing index structures or scanning. Primary key and unique index access require index traversal first.

Multiple choice technology databases
  1. 21-AUG-09

  2. 28-AUG-09

  3. 04-SEP-09

  4. 29-AUG-09

  5. 27-AUG-09

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

In Oracle SQL, NEXT_DAY returns the date of the first weekday named that is later than the given date. If today is Friday, NEXT_DAY(sysdate, 'FRIDAY') will return the following Friday, which is September 4th, 2009.

Multiple choice technology databases
  1. 8

  2. 3

  3. 5

  4. There is no such criteria

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

To join N tables, you generally need a minimum of N-1 join conditions to avoid a Cartesian product. For four tables, 4 - 1 = 3 conditions are required to link them all together in a single chain or tree.

Multiple choice technology databases
  1. Column

  2. 1966_Invoices

  3. Catch_#22

  4. #Invoices

  5. None of the above

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

In SQL, identifiers starting with numbers or containing special characters like '#' are generally invalid unless quoted. However, 'Catch_#22' is often permitted in specific SQL dialects, while 'Column' is a reserved word and '#Invoices' is often used for temporary tables.

Multiple choice technology databases
  1. a special type of store procedure, executed when certain event occurs

  2. a special type of table

  3. a special type of view

  4. All the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Multiple choice technology databases
  1. The HAVING keyword specifies a search condition for an aggregate or a group

  2. The HAVING keyword is used to select distinct values

  3. The HAVING keyword is used to join 2 or more tables.

  4. None of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Multiple choice technology databases
  1. An index is the same as alias.

  2. An index is a special way to join 2 or more tables.

  3. An index is a database table attribute, which speeds-up data search within a table.

  4. None of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Multiple choice technology databases
  1. A view is a special stored procedure executed when certain event occurs.

  2. A view is a database diagram.

  3. A view is a virtual table which results of executing a pre-compiled query. A view is not part of the physical database schema, while the regular tables are

  4. None of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Multiple choice technology databases
  1. UPDATE Persons SET LastName='Hansen' WHERE LastName='Nilsen'

  2. MODIFY Persons SET LastName='Hansen' WHERE LastName='Nilsen'

  3. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

  4. MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'

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

To change "Hansen" into "Nilsen" in the "LastName" column in the Persons table, the user needs to use SQL UPDATE statement.

UPDATE statement is used to modify the existing records in a table.

Now, let's go through each option:

A. UPDATE Persons SET LastName='Hansen' WHERE LastName='Nilsen': This option is incorrect because it will change the LastName to "Hansen" where LastName is "Nilsen". This will not change "Hansen" to "Nilsen".

B. MODIFY Persons SET LastName='Hansen' WHERE LastName='Nilsen': This option is incorrect because MODIFY is not a valid keyword in SQL. Also, this statement will change LastName to "Hansen" where LastName is "Nilsen". This will not change "Hansen" to "Nilsen".

C. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen': This option is correct because it will change LastName to "Nilsen" where LastName is "Hansen". This will change "Hansen" into "Nilsen" in the LastName column.

D. MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen': This option is incorrect because MODIFY is not a valid keyword in SQL. Also, this statement will change LastName to "Nilsen" where LastName is "Hansen". This will change "Hansen" into "Nilsen" in the LastName column.

The Answer is: C