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.
Purpose of Scope resolution operator
- Which phase of the Software Development Lifecycle (SDLC) focuses on identifying the feasibility and goals of the project?
Which of the following protocols is primarily used to assign IP addresses dynamically to devices on a network?Â
- Which of the following is a characteristic of Cross-Site Request Forgery (CSRF) attacks?
Which of the following virtualization types allows multiple operating systems to run concurrently on a single physical machine, but does not require a h...
What will be the output of the following code snippet implementing the Least Recently Used (LRU) page replacement algorithm?
def lru(pages, capac...
Artificial Intelligence (AI) and parallel processing are key characteristics associated with which generation of computers?
Which type of cyber attack involves overwhelming a server with traffic to make it unavailable to users?        Â
...In I/O scheduling, which of the following algorithms minimizes seek time but may lead to starvation of requests at the ends of the disk?Â
Which of the following is a characteristic of an intelligent agent?