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
A Correct answer
Explanation

Using the ALTER TABLE statement, constraints can be added, dropped, enabled, or disabled, but their internal structure (such as the columns they reference) cannot be directly modified. To modify a constraint's definition, you must drop it and recreate it, validating the statement as true.

Multiple choice technology databases
  1. It is a DML command

  2. It is a DDL command

  3. Provides the ability to conditionally update or insert data into a database table

  4. Provides the ability to MERGE VIEWS and INDICES of a TABLE

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

MERGE is a DML (Data Manipulation Language) command, not DDL, because it modifies existing data in tables. It provides UPSERT functionality - conditionally updating existing rows or inserting new ones based on a matching condition. Option D is incorrect because MERGE operates on table data, not on schema objects like views or indices.

Multiple choice technology databases
  1. EQUI-JOIN

  2. NONEQUI-JOIN

  3. SELF-JOIN

  4. OUTER-JOIN

  5. MERGE-JOIN

  6. TRANSACTION-JOIN

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

Standard SQL JOIN types include EQUI-JOIN (joins on equality condition), NON-EQUI-JOIN (joins on non-equality conditions like >, <, BETWEEN), SELF-JOIN (joining a table to itself), and OUTER-JOIN (includes unmatched rows with NULLs). MERGE-JOIN is a join algorithm/implementation method, not a JOIN type. TRANSACTION-JOIN is not a standard SQL concept.

Multiple choice technology databases
  1. SELECT

  2. WHERE

  3. GROUP BY

  4. FROM

  5. ORDER BY

  6. HAVING

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

The SELECT statement requires only SELECT and FROM clauses to be valid - these specify what to retrieve and where from. WHERE, GROUP BY, ORDER BY, and HAVING are optional clauses that filter rows, group results, sort output, and filter groups respectively. A query like 'SELECT column FROM table;' is perfectly valid.

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.