Section 7:64. Loading the Data into Hive Tables – Overwrite vs Append

When loading data into a Hive table using LOAD DATA INPATH or LOAD DATA LOCAL INPATH, you can also choose to overwrite or append the data in the table, similar to the INSERT statements.

To overwrite the data in the table, you can use the OVERWRITE keyword in your LOAD DATA statement. For example:

LOAD DATA INPATH <path> OVERWRITE INTO TABLE table_name;

This will replace all existing data in orders with the new data located at <path>

To append the new data to the existing data in the table, you can simply omit the OVERWRITE keyword. For example

LOAD DATA INPATH <path>INTO TABLE table_name

This will add the new data to the existing data in orders  without deleting any previous data.

It’s important to note that the OVERWRITE keyword can be potentially destructive, as it deletes all existing data in the table before loading the new data. Therefore, you should use it with caution and make sure you have a backup of the existing data before running the statement. The APPEND option is generally a safer choice if you want to preserve the existing data in the table.

Share this post