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
-
Selfjoin
-
Outerjoin
-
innerjoin
-
equijoin
A
Correct answer
Explanation
A self-join joins a table to itself, typically using table aliases to treat it as two separate copies. This is used for hierarchical data (employee-manager) or comparing rows within the same table. Option A correctly names this join type.
-
Duplicate
-
Distinct
-
Remove
-
Delete
B
Correct answer
Explanation
DISTINCT keyword in SELECT statement removes duplicate rows from the result set, returning only unique values. Options A, C, and D are not valid SQL keywords for eliminating duplicates.
-
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 as single-row (return one row) or multiple-row (return multiple rows). This classification determines which operators you can use: single-row operators (=, >, <) vs multiple-row operators (IN, ANY, ALL). Option D is correct despite slightly awkward phrasing.
-
Only one row
-
Two rows
-
Zero rows
-
There is no such subquery
A
Correct answer
Explanation
A single-row subquery returns exactly one row from the inner query, allowing use of single-row comparison operators like =, >, <, >=, <=, !=. If it returns zero or multiple rows, these operators will cause an error.
-
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 one row per unique Rollnum (multiple rows total). The outer query uses = (single-row operator), which cannot handle multiple results. This triggers the error 'single-row subquery returns more than one row'. Note: GROUPBY should be GROUP BY (missing space).
C
Correct answer
Explanation
ALL operator compares a value to EVERY value returned by a subquery. For example, salary > ALL (subquery) means salary is greater than the maximum value in the subquery. ANY compares to at least one value, IN checks for membership, and OF is not a valid operator.
-
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) includes INSERT (add new rows), UPDATE (modify existing rows), and DELETE (remove existing rows). All three actions are DML operations, so 'All of the above' is correct.
-
Insert to table tablename (….);
-
Insert into table tablename (….);
-
Insert into table tablename values (…..);
-
Any one of the above
C
Correct answer
Explanation
Correct INSERT syntax is INSERT INTO tablename VALUES (...). Option A has 'Insert to' instead of 'Insert into'. Option B is missing the VALUES keyword. Option C is correct: INSERT INTO tablename VALUES (...). Note: Option C says 'Insert into table tablename' which has an extra 'table' - the standard is just 'INSERT INTO tablename VALUES (...)'.
-
Distinct
-
Projection
-
Where
-
All of the above
C
Correct answer
Explanation
The WHERE clause filters rows based on specified conditions, returning only those rows that satisfy the criteria. DISTINCT removes duplicate rows, while projection refers to selecting specific columns in a SELECT statement.
-
Projection
-
Selection
-
Join
-
All of the above
D
Correct answer
Explanation
SQL SELECT supports projection (choosing columns), selection (filtering rows with WHERE), and join (combining tables). All three capabilities are fundamental to SELECT statements.
-
Select all columns from EMP;
-
Select distinct columns from EMP;
-
Select * from EMP;
-
All of the above
C
Correct answer
Explanation
SELECT * from EMP; is the correct SQL syntax to select all columns. The asterisk (*) wildcard represents all columns in the table.
B
Correct answer
Explanation
This statement will fail due to syntax errors: there are extra spaces (select, ename, emp) and the string literal Scott is not properly quoted with single quotes. SQL requires single quotes for string literals.
-
Structured Query Language
-
Standard Query Language
-
System Query Language
-
Simple Query Language
A
Correct answer
Explanation
SQL stands for Structured Query Language, which is the standard language for relational database management systems. It's used for querying, manipulating, and defining data in databases.
-
Distinct
-
Projection
-
Where
-
All of the above
C
Correct answer
Explanation
This is an exact duplicate of question 139501. The WHERE clause filters rows based on specified conditions. DISTINCT removes duplicates and projection selects columns.
-
Projection
-
Selection
-
Join
-
All of the above
D
Correct answer
Explanation
The SQL SELECT statement possesses three primary capabilities: selection, which filters rows using a WHERE clause; projection, which chooses specific columns to display; and joining, which combines data from multiple tables. Therefore, all of the listed capabilities are correct.