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
-
All rows of the Employee table
-
Rows of the Employee table where the set grade is ‘Y’
-
Delete 1 row
-
Nothing will be deleted
B
Correct answer
Explanation
The DELETE statement with a WHERE clause removes only those rows that satisfy the condition. In this case, only employees whose grade column contains 'Y' will be deleted. All other rows remain untouched. The DELETE without WHERE would remove all rows.
-
CHECK keyword
-
WITH CHECK keyword
-
WITH CHECK OPTION keyword
-
None of the Above
C
Correct answer
Explanation
WITH CHECK OPTION is used with updatable views to prevent modifications that would make rows invisible to the view. It ensures that INSERT or UPDATE operations result in rows that still satisfy the view's defining query, maintaining data integrity and view consistency.
-
INSERT statement
-
UPDATE statement
-
Both of the Above
-
None of the Above
C
Correct answer
Explanation
Explicit defaults can be specified in both INSERT and UPDATE statements. In INSERT, you can explicitly set a column to its default value. In UPDATE, you can reset a column back to its default value using the DEFAULT keyword. This provides flexibility in managing default values during data manipulation.
B
Correct answer
Explanation
In join conditions, specifying table names is NOT mandatory when column names are unambiguous. If a column name exists in only one of the joined tables, you can reference it directly without the table prefix. Table prefixes (or aliases) are only required when column names are ambiguous (exist in multiple tables). The claimed answer 'False' is correct.
-
9
-
11
-
5
-
12
-
None of the above
A
Correct answer
Explanation
To join N tables together, you need at minimum N-1 join conditions. This is because each join reduces the number of unconnected tables by one. Starting with 10 tables, you need 9 joins to connect them all into a single result set. For example: (T1 JOIN T2) JOIN T3 ... JOIN T10 requires 9 joins.
A
Correct answer
Explanation
A non-equi-join is defined as a join condition that uses comparison operators other than equality (=). These include operators like <, >, <=, >=, <>, BETWEEN, LIKE, etc. For example, finding employees whose salary is greater than the department average uses a non-equi-join. The statement is accurate, so 'True' is correct.
B
Correct answer
Explanation
You CAN sort SQL results by column alias - this is a standard SQL feature. The ORDER BY clause can reference column aliases defined in the SELECT list, even though the alias doesn't exist in the original table. This is because ORDER BY is logically processed after SELECT, so the aliases are available. The statement claims sorting by alias is not possible, which is false.
-
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 two main types: single-row functions (which operate on each row independently) and multiple-row functions (also called aggregate or group functions) which operate on groups of rows. Options A and B invent non-existent categories. This classification is fundamental to understanding SQL function behavior.
B
Correct answer
Explanation
Single-row functions return exactly ONE result per input row, not multiple results. This is why they're called 'single-row' functions - they maintain a one-to-one relationship between input rows and output rows. They may transform the data (change data type, format, etc.), but they never produce multiple output rows from a single input row. Multiple-row functions (aggregates) can reduce many rows to one result, but single-row functions do not.
-
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
While an inner join only returns rows with matching values in both tables, an outer join also retrieves rows from one or both tables that do not have a corresponding match in the other, filling missing values with NULL. This makes it ideal for finding unmatched records.
A
Correct answer
Explanation
In Oracle SQL, the (+) operator is used for outer joins in the WHERE clause syntax. For example, WHERE table1.column = table2.column(+) indicates a right outer join (rows from table2 are preserved). The (-) and * and + alone are not outer join operators.
-
Selfjoin
-
Outerjoin
-
innerjoin
-
equijoin
A
Correct answer
Explanation
A self-join joins a table to itself, typically to compare rows within the same table. It requires table aliases to distinguish the two instances of the table. Outer join returns all rows from one table plus matching rows from another. Inner join returns only matching rows. Equi-join is a join using = operator.