RDBMS Questions and Answers – Modification of Database

This set of RDBMS Interview Questions and Answers focuses 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: 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?

advertisement
advertisement
DELETE FROM student
WHERE marks &lt; (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
View Answer

Answer: b
Explanation: 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.
Note: Join free Sanfoundry classes at Telegram or Youtube

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”
View Answer

Answer: c
Explanation: 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

advertisement
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
View Answer

Answer: d
Explanation: Data is not inserted because, the proper syntax is
insert into <relation name> values (<data>);
advertisement

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
View Answer

Answer: c
Explanation: 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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: 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
View Answer

Answer: c
Explanation: 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
View Answer

Answer: d
Explanation: 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.

Sanfoundry Global Education & Learning Series – RDBMS.

To practice all areas of RDBMS for Interviews, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.