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. SELECT COUNT(*) FROM Persons

  2. SELECT COLUMNS(*) FROM Persons

  3. SELECT COLUMNS() FROM Persons

  4. SELECT COUNT() FROM Persons

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

SQL uses the COUNT aggregate function to return the number of records. Option A correctly uses COUNT(*) which counts all rows including nulls. Options B and C use COLUMNS which is not a valid SQL function, and Option D uses COUNT() without * which is incomplete syntax in most SQL implementations.

Multiple choice technology databases
  1. SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'

  2. SELECT * FROM Persons WHERE FirstName<>'Peter'

  3. SELECT [all] FROM Persons WHERE FirstName='Peter'

  4. SELECT * FROM Persons WHERE FirstName='Peter'

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

The correct SQL syntax for exact match is the equals operator. Option D uses SELECT * FROM Persons WHERE FirstName='Peter' which is the standard way to select all columns with an exact match condition. Option A incorrectly uses [all] brackets, Option B uses <> (not equals operator), and Option C combines [all] brackets with exact match - [all] is not valid SQL syntax.

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.