Support Questions
Find answers, ask questions, and share your expertise

how to change hive external table location.


I want to change my external table hdfs location to new path location which is Amazon S3 in my case.

I tried following query.

ALTER TABLE table_name set location 's3n://bucket/path/to/data'

But some how it is still pointing to old hdfs external path.

Is there any query I need to use in order to update hive metastore with new external data path location.

Any kind of help would be greatly appreciated .


Expert Contributor

@Girish Chaudhari

what happened right after you executed the Alter table command? Did you get any errors?

I am assuming, you tried describe extended <table_name> to determine the location that it is referring to??


@hduraiswamy I am able to execute alter query, I didn't get any errors . Yes i have tried extended describe command as well to get location info.

DROP the current table (files on HDFS are not affected for external tables), and create a new one with the same name pointing to your S3 location.


@Predrag Minovic I also tried this work around it is working partially for me as i have to recover all the table partition because somehow it doesn't detect s3 sub directories .


Check if you have provided the aws access keys correctly and if there are any exceptions reported in hive client log (e.g /tmp/<user>/hive.log).


@Rajesh Balamohan I have aws access id & secret stored in in hive-site and hdfs-site config file.


are there any exceptions reported in client log or in metastore log?

on hive terminal run below command

alter table FpML_Data set location hdfs:/file_path_in_HDFS;

HDFS: is value against fs.defaultFS property in core-site.xml

Reply my comment if in case any query...

Expert Contributor

@Girish Chaudhari

Note, when you change the location of the file by using alter command, the old data file is not moved to new location.

On your issue, 1) do you have any data files in the mentioned path?

2) Did you get any warnings / errors while you executed this ALTER command?

; ;