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. SELECT * FROM Persons WHERE FirstName LIKE '%a'

  2. SELECT * FROM Persons WHERE FirstName='%a%'

  3. SELECT * FROM Persons WHERE FirstName='a'

  4. SELECT * FROM Persons WHERE FirstName LIKE 'a%'

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

SQL LIKE with % wildcard matches patterns. Option D uses 'a%' which correctly matches any string starting with 'a' (% means any characters after). Option A uses '%a' which would match strings ending with 'a'. Option B has incorrect syntax (= without LIKE), and Option C looks for exact match 'a' only.

Multiple choice technology databases
  1. SELECT * FROM Persons SORT BY 'FirstName' DESC

  2. SELECT * FROM Persons SORT 'FirstName' DESC

  3. SELECT * FROM Persons ORDER BY FirstName DESC

  4. SELECT * FROM Persons ORDER FirstName DESC

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

SQL uses ORDER BY for sorting, with DESC for descending order. Option C has correct syntax: SELECT * FROM Persons ORDER BY FirstName DESC. Options A and B use SORT which is not valid SQL, and Option D uses ORDER without BY which is incomplete.

Multiple choice technology databases
  1. ADD NEW

  2. INSERT INTO

  3. ADD RECORD

  4. INSERT NEW

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

SQL uses INSERT INTO statement to add new data. Option B correctly identifies INSERT INTO as the statement used. Options A (ADD NEW), C (ADD RECORD), and D (INSERT NEW) are not valid SQL statements. The complete syntax would be INSERT INTO table_name VALUES (...) or INSERT INTO table_name (columns) VALUES (...).

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. Option B is the correct expansion. Options A, C, and D incorrectly use Strong or Question instead of Structured Query. SQL is the standard language for relational database management systems.

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

The asterisk (*) wildcard in SQL selects all columns from the specified table. Option D is invalid syntax (missing column names), and option C would produce an error because 'SELECT' requires a column list or *. Options B and A are incorrect - there is no 'all' keyword in SELECT statements.

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

INSERT INTO with VALUES is the correct syntax for adding a new record. The table name follows 'INSERT INTO', then VALUES with the data in parentheses. Options B, C, and D have incorrect word order or missing the table name specification.

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, use INSERT INTO TableName (ColumnName) VALUES (value). The column list in parentheses must match the values. Options B, C, and D have incorrect syntax - column placement or keyword order is wrong.

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

DELETE FROM with WHERE is the correct syntax. The WHERE clause filters which rows to delete. Options A and C are missing the WHERE keyword, and option D uses 'REMOVE' which is not a valid SQL command.

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

SELECT column_name FROM table_name retrieves a specific column. Option B shows the correct syntax. Options A (EXTRACT) and D (SELECT *) are wrong - EXTRACT is for dates/time parts, and * selects all columns not just one. Option C would work but is less standard than B.

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 standard SQL syntax to filter records based on multiple conditions is to use the WHERE clause combined with the AND operator. The correct query specifies both FirstName and LastName conditions correctly, whereas the other options use incorrect syntax or swap the values.