How to empty the table data in Hive?

To delete data from a Hive table, you can choose from the following two methods:

Option 1: Utilize the DELETE command.

  1. Open the Hive terminal or the Hive Query Editor in Hue.
  2. Remove all data from the table called “table_name”.
  3. Executing this command will delete all data in the table.

Option Two: Utilizing the TRUNCATE TABLE command.

  1. Open the Hive terminal or the Hive Query Editor in Hue.
  2. Clear the contents of the table named table_name.
  3. Executing this command will clear all data in the table.

When using the DELETE command to remove data, only the data is deleted from the table, while the structure and metadata information of the table are retained. On the other hand, when using the TRUNCATE TABLE command, not only all data in the table is deleted, but also the metadata information of the table, essentially creating a new empty table.

广告
Closing in 10 seconds
bannerAds