Which command will delete all data from a table and will not write to the rollback segment?
-
DROP
-
DELETE
-
CASCADE
-
TRUNCATE
TRUNCATE is a DDL operation that removes all rows without generating rollback data, making it faster than DELETE but non-rollbackable. DELETE generates rollback for each row, DROP removes the entire table structure, and CASCADE is a constraint option.
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) DROP - This option is incorrect because the DROP command is used to delete an entire table, including its structure, from the database. It does not delete data from a table without writing to the rollback segment.
Option B) DELETE - This option is incorrect because the DELETE command is used to delete specific rows from a table based on a condition. It does not delete all data from a table without writing to the rollback segment.
Option C) CASCADE - This option is incorrect because the CASCADE keyword is used in conjunction with the DROP command to delete dependent objects along with the table. It does not delete all data from a table without writing to the rollback segment.
Option D) TRUNCATE - This option is correct because the TRUNCATE command is used to delete all data from a table without writing to the rollback segment. It is a faster operation than DELETE as it does not generate undo logs for each deleted row.
The correct answer is D) TRUNCATE. This option is correct because it deletes all data from a table without writing to the rollback segment.