Engineering Questions with Answers - Multiple Choice Questions
MCQs on Basic SQL Operations
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?
Explanation: As keyword is used to rename.
SELECT * FROM employee WHERE dept_name="Comp Sci";
In the SQL given above there is an error . Identify the error.
c) “Comp Sci”
Explanation: For any string operations single quoted(‘) must be used to enclose.
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?
Explanation: The % character matches any substring.
’_ _ _ ’ 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
SELECT name FROM instructor WHERE dept name = ’Physics’ ORDER BY name;
By default, the order by clause lists items in ______ order.
Explanation: Specification of descending order is essential but it not for ascending.
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
SELECT name FROM instructor WHERE salary <= 100000 AND salary >= 90000;
This query can be replaced by which of the following ?
SELECT name FROM instructor WHERE salary BETWEEN 90000 AND 100000;
SELECT name FROM employee WHERE salary <= 90000 AND salary>=100000;
SELECT name FROM employee WHERE salary BETWEEN 90000 AND 100000;
SELECT name FROM instructor WHERE salary BETWEEN 100000 AND 90000;
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.
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
Explanation: The asterisk symbol “ * ” can be usedin the select clause to denote “all attributes.”
In SQL the spaces at the end of the string are removed by _______ function.
Explanation: The syntax of trim is Trim(s); where s-string.
_____ operator is used for appending two strings.
Explanation: || is the concatenation operator.