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
-
ADD NEW
-
INSERT INTO
-
ADD RECORD
-
INSERT NEW
B
Correct answer
Explanation
INSERT INTO is the correct SQL statement for adding new records to a database table. ADD NEW, ADD RECORD, and INSERT NEW are not valid SQL syntax - they may be used in other programming languages but are not part of standard SQL.
-
Replace the copybook with another.
-
The option is invalid with copy statement.
-
It allows for the same copy to be used more than once in the same code by changing the replace value.
-
Has no impact.
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.
-
Occurs clause in 01 cant be done because 01 is the top most level.
-
Who said so, you can use it, I bet!
-
Occurs clause is there to repeat fields with same format, not the records.
-
Stack will over flow.
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.
-
Strong Question Language
-
Structured Query Language
-
Structured Question Language
-
Strong Query Language
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.
-
SELECT * FROM Persons
-
SELECT [all] FROM Persons
-
SELECT Persons
-
SELECT FROM Persons
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.
-
SELECT DIFFERENT
-
SELECT UNIQUE
-
SELECT DISTINCT
-
SELECT EXACT
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.
-
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
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.
-
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, 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.
-
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
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'.
-
DELETE
-
COLLAPSE
-
REMOVE
-
ERASE
A
Correct answer
Explanation
DELETE is the standard SQL statement for removing data from database tables. Options B (COLLAPSE), C (REMOVE), and D (ERASE) are not valid SQL keywords for data deletion - they don't exist in the SQL language for this purpose.
-
EXTRACT FirstName FROM Persons
-
SELECT FirstName FROM Persons
-
SELECT Persons.FirstName
-
SELECT * FROM Persons
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.
-
SELECT * FROM Persons WHERE FirstName='Peter' AND LastName='Jackson'
-
SELECT FirstName='Peter', LastName='Jackson' FROM Persons
-
SELECT * FROM Persons WHERE FirstName<>'Peter' AND LastName<>'Jackson'
-
SELECT * FROM Persons WHERE FirstName='Jackson' AND LastName='Peter'
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.
-
SELECT * FROM Persons WHERE LastName>'Hansen' AND LastName<'Pettersen'
-
SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'
-
SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Persons
-
SELECT LastName<>'Hansen' AND LastName<>'Pettersen' FROM Persons
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.
-
SORT BY
-
SORT
-
ORDER
-
ORDER BY
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.
-
MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'
-
MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen
-
UPDATE Persons SET LastName='Hansen' INTO LastName='Nilsen'
-
UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'
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.