Sobes.tech
Junior — Middle

How can you completely delete all records from a database table?

sobes.tech AI

Answer from AI

To completely delete all records from a table in a database, the SQL command usually used is:

DELETE FROM table_name;

However, if you need to quickly clear a table and rollback is not important, you can use:

TRUNCATE TABLE table_name;

The difference:

  • DELETE removes records row by row and can be rolled back, but is slower.
  • TRUNCATE quickly clears the table, resetting data, but usually does not support rollback and does not trigger triggers.

The choice depends on the requirements for transactional integrity and performance.

How can you completely delete all records from a… - sobes.tech