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
-
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
-
Structured Query Language
-
Standard Query Language
-
System Query Language
-
Simple Query Language
A
Correct answer
Explanation
SQL stands for Structured Query Language. It's the standard language for relational database management systems used to query, manipulate, and define data.
-
Distinct
-
Projection
-
Where
-
All of the above
C
Correct answer
Explanation
The WHERE clause is used to filter rows based on specific conditions. DISTINCT removes duplicates, and projection refers to selecting specific columns (not limiting rows).
-
It gives the name and marks of all the students.
-
It does not return anything.
-
It shows an error saying” INVALID SYNTAX ERROR”
-
It shows an error saying” Single-row subquery returns more than one row
D
Correct answer
Explanation
The subquery uses GROUP BY Rollnum, which returns multiple MIN(stud_marks) values (one per unique rollnum). When compared with a single value using = in the WHERE clause, this causes the error 'single-row subquery returns more than one row' because the main query expects exactly one value to compare against.
B
Correct answer
Explanation
The SQL statement will fail because string literals in SQL must be enclosed in single quotes, not double quotes. The correct syntax would be: ename = 'Scott'. Double quotes are for identifiers, not string values.
-
Projection
-
Selection
-
Join
-
All of the above
D
Correct answer
Explanation
SQL SELECT statements have three main capabilities: Projection (selecting specific columns), Selection (filtering rows with WHERE), and Join (combining data from multiple tables). All of these are fundamental SELECT operations.
-
Select all columns from EMP;
-
Select distinct columns from EMP;
-
Select * from EMP;
-
All of the above
C
Correct answer
Explanation
To retrieve every column from a table, the standard SQL syntax uses the asterisk wildcard: SELECT * FROM EMP;. The phrase “Select all columns from EMP;” is not valid SQL, and SELECT DISTINCT applies to rows, not columns. Therefore only the asterisk option is correct.
-
They don't have to be a Primary Index column
-
They are not allowed to be a Primary Index column.
-
They are required to be a Non-Unique Primary Index
-
You can only specify one Identity Column per table.
A,D
Correct answer
Explanation
Identity columns in Teradata are independent of the Primary Index - they can be defined on non-PI columns. They are also allowed to be part of the PI, contradicting option B. Teradata enforces a strict limit of one identity column per table to maintain data integrity and avoid ambiguity in auto-generation.
-
All columns required by the query are available via the Primary index.
-
All columns required by the query are available via a Join Index.
-
All columns required by the query are available via the Hash Index
-
The PE covers the query by looking into cache to see if the same query has been run in the last 240 minutes. If it has been cached the PE doesn't have to generate steps for the AMPs.
B
Correct answer
Explanation
A Cover Query is optimized to retrieve all required columns directly from a Join Index without accessing the base table. Join Indexes pre-join and store frequently queried column combinations, allowing the optimizer to satisfy queries entirely from the index structure. This eliminates expensive joins and dramatically improves performance.
-
Join Indexes have repeating values.
-
Join Indexes do not have repeating values.
-
Join Indexes are updated automatically when their underlying rows change
-
Join Indexes are not updated automatically when their underlying rows change.
A,C
Correct answer
Explanation
Join Indexes store pre-joined data from multiple tables, naturally resulting in repeating values as the join relationship creates duplicates. Teradata automatically maintains Join Indexes when underlying base table rows change, ensuring the pre-joined data stays synchronized without manual intervention.