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
B
Correct answer
Explanation
SQL ORDER BY can absolutely sort by column aliases. You can assign an alias in the SELECT clause and then use that alias in ORDER BY. For example, 'SELECT salary*12 AS annual_sal FROM emp ORDER BY annual_sal' works perfectly.
-
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 categorized into Single-row functions (operate on each row independently) and Multiple-row functions (operate on groups of rows). Single-row includes character, number, date, conversion functions. Multiple-row includes aggregate functions like SUM, COUNT, AVG, etc.
B
Correct answer
Explanation
Single-row functions operate on single rows and return only one result per row. In contrast, multiple-row (or group) functions manipulate groups of rows to return one result per group. Therefore, the statement that single-row functions can return multiple results per row is false.
-
Character Function
-
Number Function
-
String Function
-
Date Function
C
Correct answer
Explanation
Standard SQL function categories are Character (UPPER, LOWER, SUBSTR), Number (ROUND, TRUNC, MOD), Date (SYSDATE, ADD_MONTHS, LAST_DAY), and Conversion (TO_CHAR, TO_DATE). There is no separate 'String Function' category - character functions handle string manipulation.
-
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
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.
A
Correct answer
Explanation
In nested queries, a subquery executes first, and its resulting value or set of values is passed to the main query to complete its evaluation. Hence, the statement is true.
A
Correct answer
Explanation
The LIKE operator is used in SQL WHERE clauses to perform wildcard searches using characters like percent signs and underscores. Thus, the statement is true.
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.
A
Correct answer
Explanation
A non equi-join relies on operators other than equals, such as inequalities, to relate rows between two or more tables. The statement accurately defines this concept.