This set of Database Multiple Choice Questions & Answers (MCQs) focuses on “Basic SQL Operations”.
1.
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
Explanation: As keyword is used to rename.
2.
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
Explanation: For any string operations single quoted(‘) must be used to enclose.
3.
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
Explanation: The % character matches any substring.
4. ’_ _ _ ’ 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
Explanation: None.
5.
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
Explanation: Specification of descending order is essential but it not for ascending.
6.
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
Explanation: None.
7.
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;
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.
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
Explanation: The asterisk symbol “ * ” can be usedin the select clause to denote “all attributes.”
9. In SQL the spaces at the end of the string are removed by _______ function.
a) Upper
b) String
c) Trim
d) Lower
View Answer
Explanation: The syntax of trim is Trim(s); where s-string.
10. _____ operator is used for appending two strings.
a) &
b) %
c) ||
d) _
View Answer
Explanation: || is the concatenation operator.
Sanfoundry Global Education & Learning Series – Database Management System.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Apply for Computer Science Internship
- Practice RDBMS MCQ
- Check Programming Books
- Practice Computer Science MCQs
- Practice Programming MCQs