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
A
Correct answer
Explanation
A NOT NULL constraint dictates that a column cannot store null values. Because it is directly tied to the column's definition, it must be added or removed using the MODIFY clause of the ALTER TABLE statement rather than the ADD clause, making the statement true.
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.
B
Correct answer
Explanation
An INSERT statement can insert multiple rows at once, such as when using the INSERT INTO ... SELECT syntax or multi-row insert statements. The assertion that only a single record can be inserted per execution is false, making the stored choice correct.
-
It is a DML command
-
It is a DDL command
-
Provides the ability to conditionally update or insert data into a database table
-
Provides the ability to MERGE VIEWS and INDICES of a TABLE
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.
-
EQUI-JOIN
-
NONEQUI-JOIN
-
SELF-JOIN
-
OUTER-JOIN
-
MERGE-JOIN
-
TRANSACTION-JOIN
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.
-
SELECT
-
WHERE
-
GROUP BY
-
FROM
-
ORDER BY
-
HAVING
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.
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.
-
ORACLE BASICS
-
Oracle Basics
-
oracle basics
-
oracleBasics
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.
-
ORACLE BASICS
-
ORACLEBASICS
-
oraclebasics
-
oracleBasics
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.
A
Correct answer
Explanation
SUBSTR with negative start position counts from the string's end. For 'ORACLE BASICS' (13 characters), position -6 is 'B' (6th from end). Starting there and taking 5 characters gives 'BASIC' (positions 8-12). This Oracle function is useful for extracting text from the right side.
-
01-SEP-1995
-
01-JAN-1995
-
01-JAN-1996
-
1995
-
1996
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.
-
01-MAR-1996
-
01-FEB-1996
-
07-SEP-1995
-
06-SEP-1995
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.
-
31-AUG-1995
-
30-SEP-1995
-
31-OCT-1995
-
31-DEC-1995
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.
-
ADD_MONTHS
-
COUNT
-
ROUND
-
DISTINCT
-
AVG
-
SUM
B,E,F
Correct answer
Explanation
COUNT, AVG, and SUM are group (aggregate) functions because they operate on sets of rows to return a single value. ROUND and ADD_MONTHS are single-row functions acting on individual values, while DISTINCT is an SQL query modifier keyword rather than a function.
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.