134k views
0 votes
To retain the structure of a table, while deleting all its data and releasing their storage space, execute the TRUNC command?

1 Answer

1 vote

Final answer:

The TRUNCATE command in SQL is used to remove all records from a table quickly, retaining the structure but releasing the storage space. It is faster than the DELETE command and resets the identity column if present.

Step-by-step explanation:

To retain the structure of a table while deleting all its data and releasing the storage space, you can indeed execute the TRUNCATE command. This command quickly removes all records from a table, but unlike the DELETE command, it does not generate a large number of transactions to log which makes the process much faster. Additionally, the TRUNCATE command resets the identity of the table if it has an identity column.

The correct syntax to use this command in SQL is as follows:

TRUNCATE TABLE table_name;

Keep in mind that once you execute the TRUNCATE command, you cannot retrieve the deleted data unless you have a backup.

User Fourcube
by
7.2k points