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. 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, which is the standard language for relational database management systems. It's used for querying, manipulating, and defining data in databases.

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 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.

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, which is the standard programming language used to manage and manipulate relational databases. The other options, such as Standard, System, or Simple Query Language, are incorrect expansions of the acronym and do not represent the official name.

Multiple choice technology databases
  1. Duplicate

  2. Distinct

  3. Remove

  4. Delete

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

In SQL, the DISTINCT keyword is used in SELECT statements to remove duplicate rows from the result set, returning only unique values. While options like 'Duplicate', 'Remove', and 'Delete' might seem conceptually related, they are not valid SQL keywords for this purpose. DISTINCT is the standard SQL operator specifically designed for eliminating duplicate values.

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 broadly classified based on the number of rows they return to the outer query. Single-row subqueries return only one row, whereas multiple-row subqueries return one or more rows. The other options incorrectly include non-existent concepts like double-row subqueries.

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 and one column. This type of subquery is typically used with single-row comparison operators like =, >, <, >=, or <=. If a single-row subquery returns more than one row, it will cause an error, and if it returns no rows, the result is null.

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 groups by Rollnum, returning the minimum marks for each group, which results in multiple rows. Because the outer query uses the single-value comparison operator =, it fails with a 'single-row subquery returns more than one row' error. Other options are incorrect as the query cannot execute successfully.

Multiple choice technology databases
  1. IN

  2. OF

  3. ALL

  4. ANY

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

The ALL operator in SQL compares a value to every value returned by a subquery, evaluating to true only if the comparison is true for all values. For example, 'salary > ALL (subquery)' returns true only if the salary is greater than every single value returned by the subquery. IN checks membership, ANY returns true if at least one comparison succeeds, and OF is not a valid SQL 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 (adding new rows), UPDATE (modifying existing rows), and DELETE (removing existing rows). Since all three operations are fundamental DML operations, option D is correct as it encompasses all the individual DML actions listed in the other options.

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 values is 'INSERT INTO tablename VALUES (...)' which directly inserts values into a table. Options A and B have incorrect syntax ('Insert to' and 'insert into table' are not valid). Option C correctly shows 'Insert into table tablename values' though it would typically be 'INSERT INTO tablename VALUES' without the word 'table' - but among the given choices, C is the closest to correct syntax.