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
B
Correct answer
Explanation
Standard SQL does not allow group (aggregate) functions like SUM, AVG, or COUNT directly in the WHERE clause because the WHERE clause filters rows before grouping occurs. To filter groups based on aggregate results, the HAVING clause must be used instead, making the statement false.
B
Correct answer
Explanation
It is not mandatory to specify the table name along with the column name in a join condition unless the column names are ambiguous (i.e., they exist in multiple tables). If the column names are unique across the joined tables, the database can resolve them without table prefixes, making the statement false.
-
Table1.column1=Table2.column2
-
Table1.column1=Table2.column1
-
Table1.column2=Table2.column1
-
None of the above
B
Correct answer
Explanation
An equi-join requires equality between columns with the same name from both tables. Option B shows Table1.column1 = Table2.column1, which matches identical column names. Options A and C join different columns (column1 to column2), which would be a non-equi-join unless explicitly aliased.
-
9
-
11
-
5
-
12
-
None of the above
A
Correct answer
Explanation
To join N tables together, the minimum number of join conditions required to avoid a Cartesian product is N - 1. For 10 tables, we need at least 9 join conditions. Specifying fewer will result in an incomplete join, while specifying more is not the minimum requirement.
-
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 returns all records from one table and matching records from another, or all records from both tables. The key characteristic is that it includes records without direct matches (unlike inner joins). Option A best captures this essential behavior among the choices.
A
Correct answer
Explanation
In Oracle SQL syntax, the outer join operator is (+), placed next to the column that may be null. This Oracle-specific notation indicates which side of the join allows null values for unmatched rows.
-
Having
-
Where
-
restrict
-
exclude
A
Correct answer
Explanation
The HAVING clause filters groups after aggregation, while WHERE filters individual rows before aggregation. HAVING is specifically designed to restrict which groups appear in the result set based on aggregate conditions.
-
Group By
-
NVL
-
Order By
-
Include NULL
B
Correct answer
Explanation
Group functions (like SUM, AVG, COUNT) ignore null values by default. The NVL function converts null values to a specific default value (such as 0 or a placeholder) before the group function is applied, forcing group functions to include those records. Group By and Order By are syntax clauses, and 'Include NULL' is not a standard SQL function.
-
Control Center Manager
-
Configuration Properties
-
Mapping Editor
-
Pallete
B
Correct answer
Explanation
In Oracle Warehouse Builder (OWB), parallel hints on tables are configured within the Configuration Properties of the mapping or table object. Other components like the Mapping Editor or Control Center Manager are used for designing logic or deploying and running objects, not configuring low-level physical parallel execution properties.
-
It can be used to join a maximum of three tables
-
It can be used to restrict the number of columns used in a NATURAL join
-
It can be used to access data from tables through equijoins as well as nonequijoins
-
It can be used to join tables that have columns with the same name and compatible data types
B,D
Correct answer
Explanation
The USING clause restricts the columns compared in joins to specified shared columns, resolving ambiguity from NATURAL joins. It requires columns with the same name and compatible data types for equijoins. It cannot be used for nonequijoins or to join more than two tables directly.
-
The numbers generated by a sequence can be used only for one table
-
DELETE <sequencename> would remove a sequence from the database
-
CURRVAL is used to refer to the last sequence number that has been generated
-
When the MAXVALUE limit for a sequence for reached, you can increase the MAXVALUE limit by using the ALTER SEQUENCE statement
C,D
Correct answer
Explanation
CURRVAL returns the most recently generated sequence number for the current session. When a sequence hits its MAXVALUE, its maximum limit can be increased using the ALTER SEQUENCE statement. DELETE is used for rows, not dropping database objects like sequences.
-
They can contain a subquery within a subquery.
-
They can return multiple columns as well as rows.
-
They cannot contain a subquery within a subquery.
-
They can return only one column but multiple rows.
-
They can contain group functions and GROUP BY and HAVING clauses.
-
They can contain group functions and the GROUP BY clause, but not the HAVING clause.
A,B,E
Correct answer
Explanation
Multiple-row subqueries can be nested (subquery within a subquery), can return multiple columns along with rows, and support group functions with GROUP BY and HAVING clauses for advanced data aggregation and filtering.
-
COMMIT
-
SELECT
-
CREATE
-
ROLLBACK
-
SAVEPOINT
A,C,D
Correct answer
Explanation
COMMIT and ROLLBACK explicitly end a transaction by saving or discarding changes. CREATE acts as an implicit commit - it ends the current transaction before creating the new object. SELECT and SAVEPOINT do not end transactions.