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. True

  2. False

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

SQL keywords and function names are case-insensitive in standard SQL. SELECT, select, and Select are all treated identically. However, string literals and identifiers (depending on database settings) may be case-sensitive.

Multiple choice technology databases
  1. select col1,col2 from table_a order by col2,col1 desc

  2. select col1,col2 from table_a order by 2,col1 desc

  3. select col1,col2 from table_a order by 2,1

  4. select col1,col2 from table_a order by 1,col2

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

ORDER BY accepts column names (option A) or ordinal positions (option C). Options B and D incorrectly mix ordinal positions with column names in a way that breaks SQL syntax consistency in some databases.

Multiple choice technology databases
  1. select col1 from table_a where col1 > 0 and col1 <11

  2. select col1 from table_a where col1 >= 0 and col1 <11

  3. select col1 from table_a where col1 >= 0 and col1 <= 11

  4. select col1 from table_a where col1 > 0 and col1 < =11

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

The SQL BETWEEN operator is inclusive of both endpoints. BETWEEN 0 AND 11 includes values 0 and 11, which translates to col1 >= 0 AND col1 <= 11. Options A and B incorrectly exclude one or both endpoints, and D has a syntax error with a space in the <= operator.

Multiple choice technology databases
  1. Shut down and restart the database.

  2. Use EM Database Control to recompile the object.

  3. Export the invalid objects, drop them, and then import them.

  4. Use the ALTER FUNCTION … COMPILE and ALTER VIEW … COMPILE commands.

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

EM Database Control provides a recompile option for invalid objects directly in its interface. Additionally, you can use ALTER FUNCTION ... COMPILE and ALTER VIEW ... COMPILE commands to manually recompile specific PL/SQL objects. Shutting down the database won't fix invalid objects, and export/import is unnecessarily complex for simple recompilation.

Multiple choice technology databases
  1. a is ture

  2. b is fasle

  3. b is false a is ture

  4. a is false b is ture

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

In SQL, the correct syntax for renaming a table is 'ALTER TABLE product RENAME TO pro' (or 'RENAME TO PRO' in some databases). The simple 'RENAME product TO PRO' statement is not valid SQL syntax. Therefore, statement (a) is false and statement (b) is true.

Multiple choice technology databases
  1. True

  2. False

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

This is valid Oracle SQL syntax for INSERT ALL statement, which allows multiple insert operations in a single statement. The statement would insert two rows into mytab table. However, the statement shown is incomplete (missing SELECT or semicolon in some contexts), but the core syntax shown is valid Oracle multi-table insert.