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
-
Single-row Functions and Double-row Functions
-
One-row Functions and Two-row Functions
-
Single-row Functions and Multiple-row Functions
-
None of the above
C
Correct answer
Explanation
SQL functions are broadly categorized into single-row functions, which operate on single rows and return one result per row, and multiple-row (or group/aggregate) functions, which operate on sets of rows to return a single result. Double-row or two-row functions do not exist.
B
Correct answer
Explanation
Single-row functions (like UPPER, SUBSTR, ROUND) return exactly one result per input row processed. The statement claims they can return multiple results per row, which is incorrect - that would describe aggregate functions or group functions.
-
Table1.column1=Table2.column2
-
Table1.column1=Table2.column1
-
Table1.column2=Table2.column1
-
None of the above
-
Return records which have no direct match
-
Return records which have direct match
-
Return all the records
-
None of the above
A
Correct answer
Explanation
Outer joins (LEFT, RIGHT, FULL) are specifically designed to return unmatched rows from one or both tables, along with matched rows. This is their defining purpose - unlike inner joins which only return matches. Option A correctly identifies this behavior.
A
Correct answer
Explanation
In Oracle SQL syntax, the (+) operator is placed next to the column that may be null to indicate an outer join. For example, 'WHERE table1.id = table2.id(+)' creates a right outer join. This is Oracle's legacy outer join syntax.
-
Selfjoin
-
Outerjoin
-
innerjoin
-
equijoin
A
Correct answer
Explanation
A self-join joins a table to itself, typically using table aliases to treat it as two separate copies. This is used for hierarchical data (employee-manager) or comparing rows within the same table. Option A correctly names this join type.
-
Duplicate
-
Distinct
-
Remove
-
Delete
B
Correct answer
Explanation
DISTINCT keyword in SELECT statement removes duplicate rows from the result set, returning only unique values. Options A, C, and D are not valid SQL keywords for eliminating duplicates.
-
Single-row subquery, Double-row subquery
-
Double-row subquery, Multiple-row subquery
-
Multiple-row subquery
-
Single-row subquery and Multiple subquery
D
Correct answer
Explanation
Subqueries are classified as single-row (return one row) or multiple-row (return multiple rows). This classification determines which operators you can use: single-row operators (=, >, <) vs multiple-row operators (IN, ANY, ALL). Option D is correct despite slightly awkward phrasing.
-
Only one row
-
Two rows
-
Zero rows
-
There is no such subquery
A
Correct answer
Explanation
A single-row subquery returns exactly one row from the inner query, allowing use of single-row comparison operators like =, >, <, >=, <=, !=. If it returns zero or multiple rows, these operators will cause an error.
-
It gives the name and marks of all the students.
-
It does not return anything.
-
It shows an error saying” INVALID SYNTAX ERROR”
-
It shows an error saying” Single-row subquery returns more than one row
D
Correct answer
Explanation
The subquery uses GROUP BY Rollnum, which returns one row per unique Rollnum (multiple rows total). The outer query uses = (single-row operator), which cannot handle multiple results. This triggers the error 'single-row subquery returns more than one row'. Note: GROUPBY should be GROUP BY (missing space).
C
Correct answer
Explanation
ALL operator compares a value to EVERY value returned by a subquery. For example, salary > ALL (subquery) means salary is greater than the maximum value in the subquery. ANY compares to at least one value, IN checks for membership, and OF is not a valid operator.
-
Add new rows to a table
-
Modify existing rows of a table
-
Remove existing rows from a table
-
All of the above
D
Correct answer
Explanation
DML (Data Manipulation Language) includes INSERT (add new rows), UPDATE (modify existing rows), and DELETE (remove existing rows). All three actions are DML operations, so 'All of the above' is correct.
-
Insert to table tablename (….);
-
Insert into table tablename (….);
-
Insert into table tablename values (…..);
-
Any one of the above
C
Correct answer
Explanation
Correct INSERT syntax is INSERT INTO tablename VALUES (...). Option A has 'Insert to' instead of 'Insert into'. Option B is missing the VALUES keyword. Option C is correct: INSERT INTO tablename VALUES (...). Note: Option C says 'Insert into table tablename' which has an extra 'table' - the standard is just 'INSERT INTO tablename VALUES (...)'.
-
Distinct
-
Projection
-
Where
-
All of the above
C
Correct answer
Explanation
The WHERE clause filters rows based on specified conditions, returning only those rows that satisfy the criteria. DISTINCT removes duplicate rows, while projection refers to selecting specific columns in a SELECT statement.
-
Projection
-
Selection
-
Join
-
All of the above
D
Correct answer
Explanation
SQL SELECT supports projection (choosing columns), selection (filtering rows with WHERE), and join (combining tables). All three capabilities are fundamental to SELECT statements.