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.
The ratio of number of boys and girls in a factory of 660 workers is 7:5. How many more girls should be joined to make the ratio 1:1?
The sum of three numbers is 147. If the ratio of the first to the second is 2:3 and that of second to the third is 5:8 then the second number is?Â
In a jug, there is a mixture of apple and orange juice in the ratio of 1:3. When 10 liters of Apple juice are added, the ratio of apple to orange juice ...
If the mean proportion of 0.54 and 0.24 is 'x', then find the third proportion of (x + 8.64) and (2x + 5.28) .
The ratio of the two numbers is 5:12. 120% of the first number is equal to the 30% of the second number. Find the sum of both the numbers.
Two numbers are in the ratio 7:4. After adding 2 and 6 to them respectively the ratio becomes 2:3. Find the bigger number.
The ratio of two numbers P and Q is 6: 11 respectively. When 5 is added to P and 84 is subtracted from Q, then the ratio of P and Q becomes 5: 2 respect...
If 'A' = (2/5) of 'B', 'B' = (3/4) of 'C', then find the value of (A + B) :(B + C) .
Two candles of the same height are lighted at the same time. The first is consumed in 10 hours and the second in 8 hours. Assuming that each candle burn...
Rs 1400 was divided among Anil, Bhanu and Charan in the ratio of 9:5:11 respectively. Find the amount received by Anil and Bhanu together.