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
  1. Two rows for a given column having UNIQUE key can have same values

  2. Two rows for a given column having UNIQUE key can have nulls

  3. Both option 1 and option 2 are correct.

  4. Neither option 1 nor option 2 is correct.

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

This answer is correct. Two rows for a given column having UNIQUE key can have nulls. In Oracle, there is an exception that two rows can have nulls though the UNIQUE key is defined for the given column.

Multiple choice
  1. i. and iv. are true

  2. i. and iii. are true

  3. ii. and iv. are true

  4. ii. and iii. are true

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

This answer is correct. A primary key by default checks for both not null and the uniqueness conditions. Primary key will verify whether the value inside the column is null or not, and also unique from the other values or not. A primary key can also be a composite key. It can have one or more columns as a primary key.

Multiple choice
  1. TONUMBER

  2. TO_NUMBER

  3. TOCHAR

  4. TO_CHAR

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

This answer is correct. In Oracle, TO_CHAR is the function used to convert from number to a string. If any string is given to TO_CHAR, the result will still remain in string.

Multiple choice
  1. ALTER CONSTRAINTcommand

  2. ALTER TABLE command

  3. ALTER COLUMN command

  4. ALTER QUERY command

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

This answer is correct. ALTER TABLE command is used to disable the primary key. To enable the primary key, along with ALTER TABLE command, USING INDEX and TABLESPACE also must be specified along with the command.

Multiple choice
  1. i. and iii. are true

  2. i. and iv. are true

  3. ii. and iii. are true

  4. ii. and iv. are true

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

This answer is correct because for enabling primary key constraint, ALTER TABLE is used followed by ENABLE key word. Similarly, for disabling primary key constraint, index will be dropped because the index comes along with primary key by default and since primary key constraint is not applied on the records, the index is also dropped.

Multiple choice
  1. SELECT SYSDATE+1 FROM DUAL

  2. SELECT TO_CHAR(SYSDATE+1,'MM/dd/yyyy HH:mm:ss') FROM DUAL

  3. SELECT SYSDATE+1/86400 FROM DUAL

  4. SELECT (SYSDATE+1)/86400 FROM DUAL

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

This answer is correct. SYSDATE+1 will give the next date and time component. But SYSDATE+1/86400 will give the next second of the current date and current hour and current minute because in a given day, there are 86400 seconds, i.e. 24 * 60 * 60 seconds. Hence 1/86400 will give you the current second. When the sysdate is added to 1/86400, it gives the next second of the current date, hour and minute.