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
-
CHECK keyword
-
WITH CHECK keyword
-
WITH CHECK OPTION keyword
-
None of the Above
C
Correct answer
Explanation
The WITH CHECK OPTION clause on a view ensures that any DML operation (INSERT/UPDATE) cannot create rows that the view’s defining query would exclude, protecting against modifications outside the sub‑query’s scope. The other keywords do not provide this restriction.
-
INSERT statement
-
UPDATE statement
-
Both of the Above
-
None of the Above
C
Correct answer
Explanation
Explicit DEFAULT values can be specified in both INSERT and UPDATE statements to force a column to use its defined default when the supplied value is omitted or set to DEFAULT. Therefore the option indicating both statements is correct; the others omit one context.
A
Correct answer
Explanation
An UPDATE statement modifies one or multiple rows depending on the matching criteria in the WHERE clause. It is identical to question 139649.
-
No. of rows in a table
-
No. of rows with non-null values of the expr
-
No. of distinct non-null values of the expr
-
None of the above
C
Correct answer
Explanation
COUNT(DISTINCT expr) counts unique non-null values. Unlike regular COUNT which counts total rows, DISTINCT removes duplicates before counting. NULL values are always excluded from the count.
-
Group By
-
NVL
-
Order By
-
Having
B
Correct answer
Explanation
NVL replaces null values with a specified substitute before aggregation, forcing group functions like SUM or AVG to treat nulls as a concrete value. GROUP BY controls grouping, ORDER BY sorts results, and HAVING filters groups, none of which alter null handling within aggregates.
-
HAVING
-
WHERE
-
Order By
-
Group by
A
Correct answer
Explanation
HAVING filters groups after aggregation, while WHERE filters individual rows before aggregation. You cannot use aggregate functions in WHERE, but you can in HAVING.
B
Correct answer
Explanation
Aggregate functions like COUNT, SUM, AVG cannot be used in WHERE clause because WHERE operates on individual rows before grouping. Use HAVING clause to filter on aggregate values.
-
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
DELETE with WHERE clause removes only rows matching the condition. It will delete all Employee rows where grade equals 'Y'. If no rows match, nothing is deleted.
-
Duplicate
-
Distinct
-
Remove
-
Delete
B
Correct answer
Explanation
DISTINCT keyword removes duplicate rows from query results, returning only unique values. It applies to the entire SELECT list, not just a single column.
-
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 by how many rows they return: single-row subqueries return one row (use =, >, <), multiple-row subqueries return multiple rows (use IN, ANY, ALL). Option D correctly identifies both types.
-
Only one row
-
Two rows
-
Zero rows
-
There is no such subquery
A
Correct answer
Explanation
Single-row subqueries return exactly one row (one column value). They use single-row comparison operators like =, >, <, >=, <=. If they return zero rows, the comparison fails.
C
Correct answer
Explanation
The ALL operator compares a scalar value to every value produced by a subquery, requiring the condition to hold for each row. IN checks membership, ANY (or SOME) checks against at least one row, and OF is not an SQL operator, making ALL the right choice.
-
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) statements are used to manipulate data in tables. INSERT adds new rows, UPDATE modifies existing rows, and DELETE removes rows. All three operations are DML commands.
-
Insert to table tablename (….);
-
Insert into table tablename (….);
-
Insert into table tablename values (…..);
-
Any one of the above