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

Multiple choice technology databases
  1. True

  2. False

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

Group functions (aggregate functions like COUNT, SUM, AVG, MAX, MIN) cannot be used in WHERE clause. WHERE filters individual rows before grouping. Group functions must be used in HAVING clause or SELECT list, after grouping has occurred. This is a fundamental SQL rule.

Multiple choice technology databases
  1. All rows of the Employee table

  2. Rows of the Employee table where the set grade is ‘Y’

  3. Delete 1 row

  4. Nothing will be deleted

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

The DELETE statement with a WHERE clause specifically removes only those rows that satisfy the condition. This statement will delete all employee records where the grade column equals 'Y', leaving other rows untouched.

Multiple choice technology databases
  1. CHECK keyword

  2. WITH CHECK keyword

  3. WITH CHECK OPTION keyword

  4. None of the Above

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

WITH CHECK OPTION is a clause used with updatable views that prevents INSERT or UPDATE operations on rows that would not be visible through the view. It ensures that DML operations only affect rows that satisfy the subquery defining the view.

Multiple choice technology databases
  1. INSERT statement

  2. UPDATE statement

  3. Both of the Above

  4. None of the Above

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

The DEFAULT keyword can be explicitly used in both INSERT and UPDATE statements to assign a column's default value. In INSERT, you can specify VALUES (DEFAULT), and in UPDATE, you can use SET column = DEFAULT.

Multiple choice technology databases
  1. No. of rows in a table

  2. No. of rows with non-null values of the expr

  3. No. of distinct non-null values of the expr

  4. None of the above

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

COUNT(DISTINCT expr) returns the number of unique, non-null values for the specified expression. It eliminates both NULL values and duplicate values from the count, giving the count of distinct values present.

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.