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
-
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
An outer join retrieves all rows that satisfy the join condition plus those rows from one or both tables that do not have a matching row in the other table. Inner joins only return records with a direct match, while outer joins are specifically used to preserve unmatched records that would otherwise be excluded.
A
Correct answer
Explanation
In Oracle SQL syntax, the (+) operator placed after a column name indicates an outer join. For example, WHERE table1.column1 (+) = table2.column2 creates a left outer join on table2.
-
SelfJoin
-
EquiJoin
-
OuterJoin
-
InnerJoin
A
Correct answer
Explanation
A self-join is a regular join in which a table is joined with itself, which is useful for querying hierarchical data or comparing rows within the same table. Other joins like EquiJoin, OuterJoin, and InnerJoin describe the matching condition or inclusion of unmatched rows, but do not inherently mean joining a table to itself.
-
Structured Query Language
-
Standard Query Language
-
System Query Language
-
Simple Query Language
A
Correct answer
Explanation
SQL stands for Structured Query Language. It is the standard language for managing and manipulating relational databases.
B
Correct answer
Explanation
Table names (or aliases) are only required as column prefixes when column names are ambiguous across multiple tables in the join. If column names are unique, the prefix is optional. The statement correctly identifies that it's not mandatory in all cases.
-
9
-
11
-
5
-
12
-
None of the above
A
Correct answer
Explanation
To join N tables together without creating a Cartesian product, a minimum of N-1 join conditions are required. For 10 tables, this formula yields 10 - 1 = 9 joins. Any fewer would result in incomplete relationships, while more are unnecessary.
-
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.