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

Multiple choice technology databases
  1. HAVING

  2. WHERE

  3. Order By

  4. Group by

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The HAVING clause filters grouped results after the GROUP BY operation, while WHERE filters individual rows before grouping. HAVING can use aggregate functions like COUNT, SUM, or AVG, which WHERE cannot.

Multiple choice technology databases
  1. Projection

  2. Selection

  3. Join

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The SELECT statement performs projection (selecting specific columns), selection (filtering rows with WHERE), and joining (combining data from multiple tables). These are the three fundamental capabilities of SQL queries.

Multiple choice technology databases
  1. Select all columns from EMP;

  2. Select distinct columns from EMP;

  3. Select * from EMP;

  4. All of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In SQL, the asterisk (*) wildcard character is used in the SELECT clause to specify that all columns from the target table should be returned. Options using "all columns" or "distinct columns" are syntactically invalid in standard SQL.

Multiple choice technology databases
  1. Structured Query Language

  2. Standard Query Language

  3. System Query Language

  4. Simple Query Language

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

SQL stands for Structured Query Language. It's the standard language for relational database management systems, used for querying, manipulating, and defining data structures in databases.

Multiple choice technology databases
  1. Duplicate

  2. Distinct

  3. Remove

  4. Delete

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The DISTINCT keyword is used in a SELECT statement to eliminate duplicate rows from the result set. For example, SELECT DISTINCT department FROM employees returns each department only once, regardless of how many employees belong to it.

Multiple choice technology databases
  1. Single-row subquery, Double-row subquery

  2. Double-row subquery, Multiple-row subquery

  3. Multiple-row subquery

  4. Single-row subquery and Multiple subquery

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Subqueries are categorized into two main types based on the number of rows they return: single-row subqueries (which return exactly one row and use single-row operators like =, >, <) and multiple-row subqueries (which return multiple rows and require operators like IN, ANY, or ALL).

Multiple choice technology databases
  1. Only one row

  2. Two rows

  3. Zero rows

  4. There is no such subquery

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A single-row subquery is designed to return exactly one row from the inner query. This type of subquery can be used with single-row comparison operators like =, >, <, etc. Options B and C are incorrect because they describe multi-row or no-row scenarios, while D is false as single-row subqueries are a valid SQL construct.

Multiple choice technology databases
  1. It gives the name and marks of all the students.

  2. It does not return anything.

  3. It shows an error saying” INVALID SYNTAX ERROR”

  4. It shows an error saying” Single-row subquery returns more than one row

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The subquery uses GROUPBY (should be GROUP BY) on Rollnum, which returns one minimum mark value per unique Rollnum - potentially multiple rows. The outer query uses the single-row comparison operator = with stud_marks, expecting exactly one value. When the subquery returns multiple rows (one per Rollnum group), this creates a mismatch and triggers the 'single-row subquery returns more than one row' error.

Multiple choice technology databases
  1. IN

  2. OF

  3. ALL

  4. ANY

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

ALL is a SQL operator that compares a value to EVERY value returned by a subquery. For example, 'salary > ALL (SELECT salary FROM employees)' means the salary must be greater than every salary in the subquery results. IN checks membership in a set, ANY checks if the condition is true for at least one value, and OF is not a comparison operator.

Multiple choice technology databases
  1. Add new rows to a table

  2. Modify existing rows of a table

  3. Remove existing rows from a table

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

DML (Data Manipulation Language) statements include INSERT (add new rows), UPDATE (modify existing rows), and DELETE (remove existing rows). Since all three operations are DML statements, 'All of the above' is correct. DML commands specifically manipulate data stored in database tables.

Multiple choice technology databases
  1. Insert to table tablename (….);

  2. Insert into table tablename (….);

  3. Insert into table tablename values (…..);

  4. Any one of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The correct SQL syntax for inserting a row is 'INSERT INTO tablename VALUES (...)' or 'INSERT INTO tablename (columns) VALUES (...)'. Option C shows the basic form with VALUES clause. Options A and B use incorrect syntax ('Insert to' and 'Insert into table' instead of 'INSERT INTO'). D is incorrect because not all forms shown are valid.