How to Empty Hive Table Data: TRUNCATE vs DELETE
There are two ways to clear the data of a hive table.
- You can use the TRUNCATE TABLE statement to delete all the data in a table while keeping its structure and metadata intact. The syntax for this statement is as follows:
TRUNCATE TABLE table_name;
- You can also delete data from a table using the DELETE statement, but this method deletes data row by row, making it slower than the TRUNCATE TABLE statement. The syntax for the DELETE statement is as follows:
DELETE FROM table_name;
You can choose the appropriate method to delete data from a Hive table based on actual needs and the size of the data.