33% found this document useful (3 votes)
3K views

SQL-Multiple Choice Question

The document contains a list of 40 multiple choice questions about SQL concepts and syntax. The questions cover topics such as SQL clauses, functions, keywords, data manipulation and retrieval statements. Example SQL statements are provided to demonstrate how to perform operations like selecting data, filtering rows, sorting results, updating records, joining tables, and aggregating values.

Uploaded by

Halawati Chemeh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
33% found this document useful (3 votes)
3K views

SQL-Multiple Choice Question

The document contains a list of 40 multiple choice questions about SQL concepts and syntax. The questions cover topics such as SQL clauses, functions, keywords, data manipulation and retrieval statements. Example SQL statements are provided to demonstrate how to perform operations like selecting data, filtering rows, sorting results, updating records, joining tables, and aggregating values.

Uploaded by

Halawati Chemeh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CLASS EXERCISES: SQL

NAME :________________________________________ MATRIC.NO :


_________________
1. Which SQL function is used to count the number of rows in a SQL query?
A. COUNT()
B. NUMBER()
C. SUM()
2. The FROM SQL clause is used to
A. specify range for search condition
B. Specify search condition
C. Specify what table we are selecting or deleting data from.
3. Which of the following is NOT a SQL keyword or SQL clause?
A.
INSERT
B.
SELECT
C.
UPDATE
D.
INVERT
4. The UNION SQL clause can be used with
A.
The SELECT clause only
B.
The DELETE and UPDATE clauses
C.
The UPDATE clause only
D.
None of the other three
5. What does DML stand for?
A.
Different Mode Level
B.
Data Model Language
C.
Data Mode Lane
D.
Data Manipulation language
6. Which SQL keyword is used to retrieve a maximum value?
A.
MOST
B.
TOP
C.
MAX
D.
MAXVAL
7. Which SQL statement inserts data into a table called Projects?
A.
INSERT INTO Projects (ProjectName, ProjectDescription) VALUES ('Content
Development', 'Website content development project')
B.
SAVE INTO Projects (ProjectName, ProjectDescription) VALUES ('Content
Development', 'Website content development project')
C.
INSERT Projects VALUES ('Content Development', 'Website content
development project')
D.
INSERT Projects ('Content Development', 'Website content development
project')
8. Which of the following SQL clauses is used to enter data into a SQL table?
A.
INSERT INTO
B.
ADD
C.
SELECT
D.
ENTER

9. Which of the following SQL clauses is used to DELETE data from a database
table?
A.
DELETE
B.
REMOVE
C.
DROP DATA
D.
CLEAR
10. Which of the following SQL statements is correct?
A.
SELECT CustomerName, COUNT(CustomerName) FROM Orders
B.
SELECT CustomerName, COUNT(CustomerName) FROM Orders GROUP BY
CustomerName
C.
SELECT CustomerName, COUNT(CustomerName) FROM Orders ORDER BY
CustomerName
11. What does SQL stand for?
A.
Strong Question Language
B.
Structured Query Language
C.
Structured Question Language
12. Which SQL statement is used to extract data from a database?
A.
SELECT
B.
GET
C.
OPEN
D.
EXTRACT
13. Which SQL statement is used to update data in a database?
A.
SAVE
B.
SAVE AS
C.
MODIFY
D.
UPDATE
14. With SQL, how do you select a column named "FirstName" from a table
named "Persons"?
A.
SELECT Persons.FirstName
B.
SELECT FirstName FROM Persons
C.
EXTRACT FirstName FROM Persons
15. With SQL, how do you select all the columns from a table named "Persons"?
A.
SELECT *.Persons
B.
SELECT [all] FROM Persons
C.
SELECT * FROM Persons
D.
SELECT Persons
16. With SQL, how do you select all the records from a table named "Persons"
where the value of the column "FirstName" is "Peter"?
A.
SELECT * FROM Persons WHERE FirstName<>'Peter'
B.
SELECT [all] FROM Persons WHERE FirstName LIKE 'Peter'
C.
SELECT * FROM Persons WHERE FirstName='Peter'
D.
SELECT [all] FROM Persons WHERE FirstName='Peter'

17. With SQL, how do you select all the records from a table named "Persons"
where the value of the column "FirstName" starts with an "a"?

A.
B.
C.
D.

SELECT
SELECT
SELECT
SELECT

*
*
*
*

FROM
FROM
FROM
FROM

Persons
Persons
Persons
Persons

WHERE
WHERE
WHERE
WHERE

FirstName='a'
FirstName LIKE 'a%'
FirstName LIKE '%a'
FirstName='%a%'

18. The OR operator displays a record if ANY conditions listed are true. The AND
operator displays a record if ALL of the conditions listed are
A.
False
B.
True
19. With SQL, how do you select all the records from a table named "Persons"
where the "FirstName" is "Peter" and the "LastName" is "Jackson"?
A.
SELECT * FROM Persons WHERE FirstName='Peter' AND
LastName='Jackson'
B.
SELECT FirstName='Peter', LastName='Jackson' FROM Persons
C.
SELECT * FROM Persons WHERE FirstName<>'Peter' AND
LastName<>'Jackson'
20. With SQL, how do you select all the records from a table named "Persons"
where the "LastName" is alphabetically between (and including) "Hansen" and
"Pettersen"?
A.
SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND
'Pettersen'
B.
SELECT * FROM Persons WHERE LastName>'Hansen' AND
LastName<'Pettersen'
C.
SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Persons
21. Which SQL statement is used to return only different values?
A.
SELECT DIFFERENT
B.
SELECT UNIQUE
C.
SELECT DISTINCT
22. Which SQL keyword is used to sort the result-set?
A.
ORDER BY
B.
SORT
C.
ORDER
D.
SORT BY
23. With SQL, how can you return all the records from a table named "Persons"
sorted descending by "FirstName"?
A.
SELECT * FROM Persons SORT BY 'FirstName' DESC
B.
SELECT * FROM Persons ORDER FirstName DESC
C.
SELECT * FROM Persons SORT 'FirstName' DESC
D.
SELECT * FROM Persons ORDER BY FirstName DESC
24. With SQL, how can you insert a new record into the "Persons" table?
A.
INSERT INTO Persons VALUES ('Jimmy', 'Jackson')
B.
INSERT VALUES ('Jimmy', 'Jackson') INTO Persons
C.
INSERT ('Jimmy', 'Jackson') INTO Persons]

25. How can you change "Hansen" into "Nilsen" in the "LastName" column in the
Persons table?

A.
B.
C.
D.

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


MODIFY Persons SET LastName='Nilsen' WHERE LastName='Hansen'
MODIFY Persons SET LastName='Hansen' INTO LastName='Nilsen
UPDATE Persons SET LastName='Nilsen' WHERE LastName='Hansen'

26. With SQL, how can you delete the records where the "FirstName" is "Peter" in
the Persons Table?
A.
DELETE FROM Persons WHERE FirstName = 'Peter'
B.
DELETE ROW FirstName='Peter' FROM Persons
C.
DELETE FirstName='Peter' FROM Persons
27. With SQL, how can you return the number of records in the "Persons" table?
A.
SELECT COUNT() FROM Persons
B.
SELECT COLUMNS() FROM Persons
C.
SELECT COLUMNS(*) FROM Persons
D.
SELECT COUNT(*) FROM Persons
28. If you don't specify ASC or DESC after a SQL ORDER BY clause, the following
is used by default:
A.
ASC
B.
DESC
C.
There is no default value.
29. When inserting data in a table do you always have to specify a list of all
column names you are inserting values for?
A.
No
B.
Yes
30. Which of the following 3 SQL statements is correct?
A.
SELECT Username, Password FROM Users
B.
SELECT Username AND Password FROM Users
C.
SELECT Username, Password WHERE Username = 'user1'
31. What is a database cursor?
A.
Cursor is acronym for Current Set Of Records and is a database object
pointing to a currently selected set of records.
B.
A cursor is SQL keyword specifying a retrieved data order.
C.
A blinking vertical line that indicates the location of the next input on the
display screen.
32. What does follow after the SQL WHERE clause?
A.
Definition of the condition to be met for the rows to be returned.
B.
A list of columns to be selected.
C.
The name of the table we are selecting from.
33. What does the ALTER TABLE clause do?
A.
The SQL ALTER TABLE clause modifies a table definition by altering,
adding, or deleting table columns and/or constraints.
B.
The SQL ALTER TABLE clause is used to insert data into database table.
C.
THE SQL ALTER TABLE deletes data from database table.
D.
The SQL ALTER TABLE clause is used to delete a database table.
34. What is the difference between the WHERE and HAVING SQL clauses?
A.
The WHERE and the HAVING clauses are identical
B.
The HAVING SQL clause condition(s) is applied to all rows in the result set
before the WHERE clause is applied (if present). The WHERE clause is used

C.

only with SELECT SQL statements and specifies a search condition for an
aggregate or a group.
The WHERE SQL clause condition(s) is applied to all rows in the result set
before the HAVING clause is applied (if present). The HAVING clause is
used only with SELECT SQL statements and specifies a search condition for
an aggregate or a group.

35. What is the purpose of the SQL AS clause?


A.
The AS SQL clause is used change the name of a column in the result set
or to assign a name to a derived column.
B.
The AS clause is used with the JOIN clause only.
C.
The AS clause defines a search condition.
36. The IN SQL keyword
A. Is used with the DISTINCT SQL keyword only.
B. Determines if a value matches any of the values in a list or a sub-query.
C. Defines the tables we are selecting or deleting data from
37. The UPDATE SQL clause can
A. Update only one row at a time.
B. Update more than one row at a time.
C. Delete more than one row at a time.
D. Delete only one row at a time.
38. The LIKE SQL keyword is used along with ...
A.
WHERE clause.
B.
GROUP BY clause.
C.
ORDER BY clause.
D.
JOIN clause.
39. Which of the following statements gets the total value of the column 'Price' in
the 'Sales' table?
A.
SELECT ADD(Price) FROM Sales
B.
SELECT SUM(Price) FROM Sales
C.
SELECT TOTAL(Price) FROM Sales
D.
SELECT SUM(Price) WHERE Sales
40. Which of the following SQL statements selects the total number of orders
from the Sales table?
OrderNumb
er
1
2
A.
B.
C.

Date

CustomerID

12/12/2005
13/12/2005

13
17

SELECT AVG(OrderNumber) FROM Sales


SELECT COUNT(*) FROM Sales
SELECT SUM(OrderNumber) FROM Sales

You might also like