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

  2. False

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

SQL allows aliases to be defined on both tables (to shorten references and qualify columns in joins) and columns (to rename output headers and make them descriptive). This simplifies query writing and significantly improves the readability of complex SQL queries, making the statement true.

Multiple choice technology databases
  1. ORACLE BASICS

  2. Oracle Basics

  3. oracle basics

  4. oracleBasics

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

INITCAP converts each word to title case - first letter uppercase, remaining letters lowercase. For 'ORACLE BASICS', it produces 'Oracle Basics' with both words properly capitalized. This Oracle string function is commonly used for formatting names and headings.

Multiple choice technology databases
  1. ORACLE BASICS

  2. ORACLEBASICS

  3. oraclebasics

  4. oracleBasics

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

The || operator performs string concatenation in Oracle SQL. CONCAT('ORACLE' || 'BASICS') first evaluates 'ORACLE' || 'BASICS' to 'ORACLEBASICS', then CONCAT receives this single result. The output is 'ORACLEBASICS' with no space added. Option A shows a space that isn't present in the input.

Multiple choice technology databases
  1. 01-SEP-1995

  2. 01-JAN-1995

  3. 01-JAN-1996

  4. 1995

  5. 1996

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

TRUNC with 'YEAR' precision truncates a date to January 1st of its year. For '01-SEP-1995', this yields '01-JAN-1995' - same year, first day. The 'YEAR' format zeroes month and day to 1. TRUNC is different from ROUND which would round up to next year on certain dates.

Multiple choice technology databases
  1. 01-MAR-1996

  2. 01-FEB-1996

  3. 07-SEP-1995

  4. 06-SEP-1995

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

ADD_MONTHS adds the specified number of months to a date. Starting September 1, 1995 and adding 6 months: Sep->Oct(1), Nov(2), Dec(3), Jan(4), Feb(5), Mar(6) = March 1, 1996. This function handles year rollovers automatically. Option C shows 6 days instead of months.

Multiple choice technology databases
  1. 31-AUG-1995

  2. 30-SEP-1995

  3. 31-OCT-1995

  4. 31-DEC-1995

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

LAST_DAY returns the last date of the month for any given date in that month. For September 1, 1995, it returns September 30, 1995 (September's last day). This is useful for month-end calculations. Option A shows August (previous month), not September.

Multiple choice technology databases
  1. True

  2. False

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

WHERE clause filters individual rows before any grouping occurs. HAVING is used to filter groups after GROUP BY is applied. The statement claims WHERE restricts groups, which is incorrect - it restricts rows, not groups.

Multiple choice technology databases
  1. WHERE clause

  2. GROUP BY clause

  3. GROUP functions

  4. DISTINCT keyword

  5. FROM clause

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

A view is not deletable if its query contains aggregate functions, GROUP BY clauses, or the DISTINCT keyword, as the system cannot map the deletion to specific source table rows. A view must have a FROM clause and can optionally have a WHERE clause without affecting delete support.

Multiple choice technology databases
  1. select count(*) from orders;

  2. select count(1) from orders;

  3. select count(3) from orders;

  4. select count(5) from orders;

Reveal answer Fill a bubble to check yourself
B Correct answer
Multiple choice technology web technology
  1. True

  2. False

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

Indexes significantly improve SELECT query performance by providing fast lookup paths. However, they impose overhead on DML operations (INSERT, UPDATE, DELETE) because the index must be updated alongside the table data. This is a fundamental trade-off in database design - faster reads come at the cost of slower writes.

Multiple choice technology databases
  1. DECLARE

  2. BEGIN

  3. EXCEPTION

  4. END

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

In PL/SQL block structure, only the execution section (BEGIN) and its terminator (END) are mandatory. The declaration section (DECLARE) is optional and only needed when declaring variables, cursors, or exceptions. The exception handling section (EXCEPTION) is also optional.