DB Draft
DB Draft
a) On
b) Using
c) Set
d) Where
Answer: a
2. Which of the join operations do not preserve non matched tuples?
a) Left outer join
b) Right outer join
c) Inner join
d) Natural join
Answer: c
Explanation: INNER JOIN: Returns all rows when there is at least one match in BOTH tables.
3.
SELECT *
FROM student JOIN takes USING (ID);
The above query is equivalent to
a)
SELECT *
FROM student INNER JOIN takes USING (ID);
b)
SELECT *
FROM student OUTER JOIN takes USING (ID);
c)
SELECT *
FROM student LEFT OUTER JOIN takes USING (ID);
d) None of the mentioned
Answer: a
4. What type of join is needed when you wish to include rows that do not have matching values?
a) Equi-join
b) Natural join
c) Outer join
d) All of the mentioned
Answer: c
5. How many tables may be included with a join?
a) One
b) Two
c) Three
d) All of the mentioned
Answer: d
6. Which are the join types in join condition:
a) Cross join
b) Natural join
c) Join with USING clause
d) All of the mentioned
Answer: d
7. How many join types in join condition:
a) 2
b) 3
c) 4
d) 5
Answer: d
Explanation: Types are inner join, left outer join, right outer join, full join, cross join.
8. Which join refers to join records from the right table that have no matching key in the left
table are include in the result set:
a) Left outer join
b) Right outer join
c) Full outer join
d) Half outer join
Answer: b
Explanation: RIGHT OUTER JOIN: Return all rows from the right table and the matched rows
from the left table.
9. The operation which is not considered a basic operation of relational algebra is
a) Join
b) Selection
c) Union
d) Cross product
Answer: a
10. In SQL the statement select * from R, S is equivalent to
a) Select * from R natural join S
b) Select * from R cross join S
c) Select * from R union join S
d) Select * from R inner join S
Answer: b
2. Here which of the following displays the unique values of the column?
SELECT ________ dept_name
FROM instructor;
a) All
b) From
c) Distinct
d) Name
Answer: c
3. The ______ clause allows us to select only those rows in the result relation of the ____ clause
that satisfy a specified predicate.
a) Where, from
b) From, select
c) Select, from
d) From, where
Answer: a
4. The query given below will not give an error. Which one of the following has to be replaced to
get the desired output?
SELECT ID, name, dept name, salary * 1.1
WHERE instructor;
a) Salary*1.1
b) ID
c) Where
d) Instructor
Answer: c
5. The ________ clause is used to list the attributes desired in the result of a query.
a) Where
b) Select
c) From
d) Distinct
Answer: b
6. This Query can be replaced by which one of the following?
SELECT name, course_id
FROM instructor, teaches
WHERE instructor_ID= teaches_ID;
a) Select name,course_id from teaches,instructor where instructor_id=course_id;
b) Select name, course_id from instructor natural join teaches;
c) Select name, course_id from instructor;
d) Select course_id from instructor join teaches;
Answer: b
7.
SELECT * FROM employee WHERE salary>10000 AND dept_id=101;
Which of the following fields are displayed as output?
a) Salary, dept_id
b) Employee
c) Salary
d) All the field of employee relation
Answer: d
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
Answer: c
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
Answer: c
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) $
Answer: a
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
Answer: b
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
Answer: d
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
Answer: c
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;
Answer: a
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
Answer: b
9. In SQL the spaces at the end of the string are removed by _______ function.
a) Upper
b) String
c) Trim
d) Lower
Answer: c
4. Inorder to ensure that the value of budget is non-negative which of the following should be
used?
a) Check(budget>0)
b) Check(budget<0)
c) Alter(budget>0)
d) Alter(budget<0)
Answer: a
Explanation: A common use of the check clause is to ensure that attribute values satisfy specified
conditions, in effect creating a powerful type system.
5. Foreign key is the one in which the ________ of one relation is referenced in another relation.
a) Foreign key
b) Primary key
c) References
d) Check constraint
Answer: b
6.