Engineering Questions with Answers - Multiple Choice Questions

MCQs on Basic SQL Operations

1 - Question

SELECT name ____ instructor name, course id
FROM instructor, teaches
WHERE instructor.ID= teaches.ID;

Which keyword must be used here to rename the field name?
a) From
b) Rename
c) As
d) Join

View Answer

Answer: c
Explanation: As keyword is used to rename.




2 - Question

SELECT * FROM employee WHERE dept_name="Comp Sci";

In the SQL given above there is an error . Identify the error.
a) Dept_name
b) Employee
c) “Comp Sci”
d) From

View Answer

Answer: c
Explanation: For any string operations single quoted(‘) must be used to enclose.




3 - Question

SELECT emp_name
FROM department
WHERE dept_name LIKE ’ _____ Computer Science’;

Which one of the following has to be added into the blank to select the dept_name which has Computer Science as its ending string?
a) %
b) _
c) ||
d) $

View Answer

Answer: a
Explanation: The % character matches any substring.




4 - Question

’_ _ _ ’ matches any string of ______ three characters. ’_ _ _ %’ matches any string of at ______ three characters.
a) Atleast, Exactly
b) Exactly, Atleast
c) Atleast, All
d) All, Exactly

View Answer

Answer: b
Explanation: None.




5 - Question

SELECT name
FROM instructor
WHERE dept name = ’Physics’
ORDER BY name;

By default, the order by clause lists items in ______ order.
a) Descending
b) Any
c) Same
d) Ascending

View Answer

Answer: d
Explanation: Specification of descending order is essential but it not for ascending.




6 - Question

SELECT *
FROM instructor
ORDER BY salary ____, name ___;

To display the salary from greater to smaller and name in ascending order which of the following options should be used?
a) Ascending, Descending
b) Asc, Desc
c) Desc, Asc
d) Descending, Ascending

View Answer
Answer: c
Explanation: None.

 




7 - Question

SELECT name
FROM instructor
WHERE salary <= 100000 AND salary >= 90000;

This query can be replaced by which of the following ?
a)

SELECT name
FROM instructor
WHERE salary BETWEEN 90000 AND 100000;

b)

SELECT name
FROM employee
WHERE salary <= 90000 AND salary>=100000;

c)

SELECT name
FROM employee
WHERE salary BETWEEN 90000 AND 100000;

d)

SELECT name
FROM instructor
WHERE salary BETWEEN 100000 AND 90000;
View Answer

Answer: a
Explanation: SQL includes a between comparison operator to simplify where clauses that specify that a value be less than or equal to some value and greater than or equal to some other value.




8 - Question

SELECT instructor.*
FROM instructor, teaches
WHERE instructor.ID= teaches.ID;

This query does which of the following operation?
a) All attributes of instructor and teaches are selected
b) All attributes of instructor are selected on the given condition
c) All attributes of teaches are selected on given condition
d) Only the some attributes from instructed and teaches are selected

View Answer

Answer: b
Explanation: The asterisk symbol “ * ” can be usedin the select clause to denote “all attributes.”




9 - Question

In SQL the spaces at the end of the string are removed by _______ function.
a) Upper
b) String
c) Trim
d) Lower

View Answer

Answer: c
Explanation: The syntax of trim is Trim(s); where s-string.




10 - Question

 _____ operator is used for appending two strings.
a) &
b) %
c) ||
d) _

View Answer

Answer: c
Explanation: || is the concatenation operator.

Get weekly updates about new MCQs and other posts by joining 18000+ community of active learners