Question
Which SQL command is used to remove only specific rows
from a table while preserving the structure and other rows?Solution
The DELETE command in SQL is used to remove specific rows from a table based on a WHERE clause condition. Unlike DROP or TRUNCATE, which impact the entire table, DELETE operates on a more granular level, enabling selective removal of data while preserving the table structure and any other rows. For example: DELETE FROM employees WHERE department = 'Sales'; This query removes only the rows from the employees table where the department is 'Sales', leaving all other rows intact. Additionally, the DELETE command logs each deleted row, making it possible to rollback transactions if the database supports it (e.g., in databases using transaction control). This makes DELETE particularly useful for scenarios where precision and rollback capabilities are required. Explanation of Incorrect Options: A) DROP : The DROP command is used to completely remove a table or database, including its structure. It is not selective and deletes the entire object. B) TRUNCATE : While TRUNCATE removes all rows from a table, it does not allow selective deletion. Furthermore, TRUNCATE is faster but does not log individual row deletions, making rollback impossible in most cases. D) REMOVE : This is not a valid SQL command. E) UPDATE : The UPDATE command is used to modify existing data, not to delete it.
Which state is the largest producer of Sugarcane in India in 2019?
Sum of three positive numbers is 120. If the ratio of the first and second number is 5:7, respectively while difference between the first and third numb...
A registered trade union can change its name with the prior consent of:
Who is the only Prime Minister who never faced the parliament during his tenure?
Kalidasa's works include:
I. Abhijnanashakuntalam
II. Meghadutam
III. Raghuvamsa
IV. Malvikagnimitram
V. Ritusamhara<...
In this section you find a number of sentences, parts of which are underlined. You may also find only a group of words which is underlined. For each und...
What does the term "out of order" typically refer to in the context of loans?
Which of the following is/are the machinery for the settlement of Industrial disputes?
I. Labour Court
II. ...
If sin A = 4/5, then (3 − tan A) (2 + cos A) is:
The average weight of a group of five persons, A, B, C, D, and E is 100 kg. If another person K joins the group then the average weight of the group is ...