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 mainframe
  1. Replace the copybook with another.

  2. The option is invalid with copy statement.

  3. It allows for the same copy to be used more than once in the same code by changing the replace value.

  4. Has no impact.

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

The REPLACING option allows text substitution in copybooks, enabling the same copybook to be used multiple times with different values by changing what gets replaced during compilation. It does not replace the entire copybook (A), is valid with COPY statement (B is wrong), and definitely has an impact.

Multiple choice technology mainframe
  1. Occurs clause in 01 cant be done because 01 is the top most level.

  2. Who said so, you can use it, I bet!

  3. Occurs clause is there to repeat fields with same format, not the records.

  4. Stack will over flow.

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

While the OCCURS clause is technically permitted at 01 level in COBOL, the reasoning in option C correctly identifies its semantic purpose - OCCURS is designed to repeat fields within a record structure, not entire records. Options A and B are incorrect explanations. Stack overflow (D) is irrelevant.

Multiple choice technology databases
  1. Strong Question Language

  2. Structured Query Language

  3. Structured Question Language

  4. Strong Query Language

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

SQL stands for Structured Query Language, the standard language for managing and manipulating relational databases. Options A, C, and D incorrectly substitute 'Query' with 'Question' or use 'Strong' instead of 'Structured', which are not the correct expansion of the SQL acronym.

Multiple choice technology databases
  1. SELECT * FROM Persons

  2. SELECT [all] FROM Persons

  3. SELECT Persons

  4. SELECT FROM Persons

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

In SQL, the asterisk (*) wildcard character is used to select all columns from a table. The correct syntax is 'SELECT * FROM table_name' as shown in option A. Options B, C, and D use incorrect syntax - SQL doesn't use [all] keyword this way, requires a column list or *, and cannot have empty SELECT clause.

Multiple choice technology databases
  1. SELECT DIFFERENT

  2. SELECT UNIQUE

  3. SELECT DISTINCT

  4. SELECT EXACT

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

The DISTINCT keyword in SQL eliminates duplicate rows from the result set, returning only unique (different) values. The correct syntax is 'SELECT DISTINCT column_name' as shown in option C. Options A, B, and D use keywords that don't exist in standard SQL for this purpose.

Multiple choice technology databases
  1. INSERT INTO Persons VALUES ('Jimmy', 'Jackson')

  2. INSERT VALUES ('Jimmy', 'Jackson') INTO Persons

  3. INSERT ('Jimmy', 'Jackson') INTO Persons

  4. INSERT VALUES ('Jimmy', 'Jackson')

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

The correct SQL syntax for inserting a new record is 'INSERT INTO table_name VALUES (values)' as shown in option A. Options B, C, and D have incorrect syntax - they either place keywords in wrong order, omit required keywords, or miss the table name entirely.

Multiple choice technology databases
  1. INSERT INTO Persons (LastName) VALUES ('Olsen')

  2. INSERT ('Olsen') INTO Persons (LastName)

  3. INSERT INTO Persons ('Olsen') INTO LastName

  4. INSERT INTO Persons ('Olsen')

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

When inserting into specific columns, the correct SQL syntax is 'INSERT INTO table_name (column_name) VALUES (value)' as shown in option A. Options B, C, and D have incorrect syntax with misplaced or missing column specifications and VALUES keyword.

Multiple choice technology databases
  1. DELETE ROW FirstName='Peter' FROM Persons

  2. DELETE FROM Persons WHERE FirstName = 'Peter'

  3. DELETE FirstName='Peter' FROM Persons

  4. REMOVE FROM Persons WHERE FirstName = 'Peter'

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

The standard SQL syntax to delete records from a table is 'DELETE FROM table_name WHERE condition'. The correct option follows this syntax perfectly, whereas the other options use invalid keywords like 'DELETE ROW' or 'REMOVE FROM'.

Multiple choice technology databases
  1. EXTRACT FirstName FROM Persons

  2. SELECT FirstName FROM Persons

  3. SELECT Persons.FirstName

  4. SELECT * FROM Persons

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

The correct SQL syntax for selecting a specific column is 'SELECT column_name FROM table_name' as shown in option B. Option A uses EXTRACT which is for date/time parts, option C uses table.column format without proper context, and option D uses the wildcard to select all columns instead of just FirstName.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'

  2. SELECT FirstName='Peter', LastName='Jackson' FROM Persons

  3. SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson'

  4. SELECT * FROM Persons WHERE FirstName='Jackson' AND LastName='Peter'

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

The correct SQL syntax uses SELECT * with WHERE clause and AND operator to filter multiple conditions. Option A correctly combines FirstName='Peter' AND LastName='Jackson' to find records matching both criteria exactly. Option B incorrectly tries to select column values as the result, Option C uses <> (not equals) which would exclude Peter Jackson, and Option D swaps the first and last names.

Multiple choice technology databases
  1. SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName<'Pettersen'

  2. SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

  3. SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Persons

  4. SELECT LastName<>'Hansen' AND LastName<>'Pettersen' FROM Persons

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

The BETWEEN operator in SQL is inclusive and selects values within a range. Option B correctly uses BETWEEN 'Hansen' AND 'Pettersen' to get all LastNames alphabetically from Hansen through Pettersen. Option A uses > and < which would exclude the boundary values, and Options C and D have incorrect syntax or operators.

Multiple choice technology databases
  1. SORT BY

  2. SORT

  3. ORDER

  4. ORDER BY

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

SQL uses the ORDER BY clause to sort result sets, not SORT or SORT BY. Option D correctly identifies ORDER BY as the keyword used with ASC or DESC to control sort direction. Options A, B, and C are not valid SQL keywords for sorting.

Multiple choice technology databases
  1. MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'

  2. MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen

  3. UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen'

  4. UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

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

SQL uses the UPDATE statement with SET clause to modify data. Option D has the correct syntax: UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'. The SET clause specifies the new value, and WHERE identifies which rows to update. Options A, B, and C all use MODIFY keyword which doesn't exist in SQL, or have incorrect INTO syntax.