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
-
SELECT COUNT(*) FROM Persons
-
SELECT COLUMNS(*) FROM Persons
-
SELECT COLUMNS() FROM Persons
-
SELECT COUNT() FROM Persons
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.
-
SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'
-
SELECT * FROM Persons WHERE FirstName<>'Peter'
-
SELECT [all] FROM Persons WHERE FirstName='Peter'
-
SELECT * FROM Persons WHERE FirstName='Peter'
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.
-
SELECT * FROM Persons WHERE FirstName LIKE '%a'
-
SELECT * FROM Persons WHERE FirstName='%a%'
-
SELECT * FROM Persons WHERE FirstName='a'
-
SELECT * FROM Persons WHERE FirstName LIKE 'a%'
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.
-
SELECT * FROM Persons SORT BY 'FirstName' DESC
-
SELECT * FROM Persons SORT 'FirstName' DESC
-
SELECT * FROM Persons ORDER BY FirstName DESC
-
SELECT * FROM Persons ORDER FirstName DESC
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.
C
Correct answer
Explanation
The SELECT statement is the standard SQL command used to retrieve or extract data from a database. OPEN, EXTRACT, and GET are not the standard SQL keywords used for querying and retrieving records.
-
UPDATE
-
MODIFY
-
SAVE
-
SAVE AS
A
Correct answer
Explanation
The UPDATE statement is the standard SQL command used to modify existing records in a database table. MODIFY, SAVE, and SAVE AS are not standard SQL keywords used for updating existing row data.
-
ADD NEW
-
INSERT INTO
-
ADD RECORD
-
INSERT NEW
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 (...).
-
Strong Question Language
-
Structured Query Language
-
Structured Question Language
-
Strong Query Language
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.
-
SELECT * FROM Persons
-
SELECT [all] FROM Persons
-
SELECT Persons
-
SELECT FROM Persons
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.
-
SELECT DIFFERENT
-
SELECT UNIQUE
-
SELECT DISTINCT
-
SELECT EXACT
C
Correct answer
Explanation
The DISTINCT keyword eliminates duplicate rows from the result set, returning only unique values. Options A, B, and D are not valid SQL keywords - DIFFERENT, UNIQUE, and EXACT do not exist in standard SQL SELECT statements.
-
INSERT INTO Persons VALUES ('Jimmy', 'Jackson')
-
INSERT VALUES ('Jimmy', 'Jackson') INTO Persons
-
INSERT ('Jimmy', 'Jackson') INTO Persons
-
INSERT VALUES ('Jimmy', 'Jackson')
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.
-
INSERT INTO Persons (LastName) VALUES ('Olsen')
-
INSERT ('Olsen') INTO Persons (LastName)
-
INSERT INTO Persons ('Olsen') INTO LastName
-
INSERT INTO Persons ('Olsen')
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.
-
DELETE ROW FirstName='Peter' FROM Persons
-
DELETE FROM Persons WHERE FirstName = 'Peter'
-
DELETE FirstName='Peter' FROM Persons
-
REMOVE FROM Persons WHERE FirstName = 'Peter'
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.
-
DELETE
-
COLLAPSE
-
REMOVE
-
ERASE
A
Correct answer
Explanation
DELETE is the SQL statement for removing rows from a table. Options B, C, and D (COLLAPSE, REMOVE, ERASE) are not valid SQL commands for deleting data.