RDBMS Interview Questions and Answers on “Modification of Database”.
1. Insert the appropriate key word in the blank in the query ( A is a relation)
delete ______ A
where P < 5;
a) all
b) from
c) with
d) in
Answer: a
Clarification: the from key word is specified beside delete clause to indicate the relation from which the tuple needs to be deleted.
2. How many relations can a delete command operate on?
a) 0
b) 1
c) 2
d) Infinitely many
Answer: b
Clarification: The delete command can operate only on one relation. You cannot give commands like delete R1, R2.
3. What is the result of the following query?
DELETE FROM student WHERE marks < (SELECT avg(marks) FROM student);
a) The query deletes all the tuples whose marks are greater than the average marks
b) The query deletes all the tuples whose marks are less than the average marks
c) The query deletes all the values under the marks attribute which are less than the average
d) The query is syntactically wrong and does not execute
Answer: b
Clarification: The query deletes all the tuples from the student relation as per the condition specified in the where clause i.e. wherever the marks are less than average marks.
4. What is the format of entering date into a database while inserting data into it?
a) YYYY-MM-DD
b) “YYYY-MM-DD”
c) ‘YYYY-MM-DD’
d) “DD-MM-YYYY”
Answer: c
Clarification: The correct format for entering date into the database while inserting data is
‘YYYY-MM-DD’.
5. Choose the correct option regarding the following query
INSERT INTO course ('CS-67' , 'course name', 'any' , 5);
a) Data is inserted into the course relation
b) Data is not inserted into the course relation due to incorrect specification
c) Data is inserted into the CS-67 relation
d) Data is not inserted due to the incorrect use of syntax
Answer: d
Clarification: Data is not inserted because, the proper syntax is
insert into values ();
6. To change a value in a tuple without changing all the values in the tuple, we use the _____ statement
a) insert
b) insert some
c) update
d) alter
Answer: c
Clarification: To change a value in a tuple without changing the entire values in the tuple, we use the update statement. Eg: update employee set salary = salary*1.5;
7. What does the following query do?
UPDATE student SET marks = marks*1.10;
a) It increases the marks of all the students by 10%
b) It decreases the marks of all the students by 90%
c) It increases the marks of all the students by 110%
d) It is syntactically wrong
Answer: a
Clarification: The update clause is used to edit a specific value in the tuple. The set command is used to set the value of an attribute in a tuple.
8. State true or false: We cannot write a where clause under an update command
a) True
b) False
Answer: b
Clarification: Writing a where clause under the update statement enables us to specify a condition for the selection of tuples whose values need to be updated.
9. Scalar Subqueries can be used in the SQL update statement when they are used under the ____ clause
a) where
b) with
c) set
d) end
Answer: c
Clarification: SQL subqueries that can occur wherever a value is permitted provided the subquery gives only one tuple with a single attribute are called Scalar subqueries. Scalar Subqueries can be used in the SQL update statement when they are used under the set clause.
10. Which of the following cannot be used to modify the data in a database
a) update
b) insert
c) delete
d) drop
Answer: d
Clarification: The drop keyword is used to delete the entire relation leaving no trace of it in the memory. Thus it cannot be used to edit the data in the relation.
