Change Hive Database Location

Is there a way to change the location that the database points to?

I tried the following methods:

  • alter database <my_db> set DBPROPERTIES('hive.warehouse.dir'='<new_hdfs_loc>');

  • alter database <my_db> set DBPROPERTIES('location'='<new_hdfs_loc>');

  • alter database <my_db> set location '<new_hdfs_loc>';

The first two alter statements simply changed the properties of the database, however the database still points to the same location; while the third alter statement gave me a semantics error.

Any help would be greatly appreciated.

+4
source share
1 answer

After some trial and error, I found out that Hive does not support the following two conditions when running ALTER in the database.

  • Cannot change directory location or database name.
  • It is not allowed to remove or remove db properties that were previously defined.

, Hive Metastore HDFS. http://gaganonthenet.com/2015/02/23/hive-change-location-for-database-or-schema/

, :

, , . , , . HDFS . . https://issues.apache.org/jira/browse/HIVE-1537 https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-AlterTable/PartitionLocation .

, ALTER TABLE <table> SET LOCATION "/path/to/new/location"; .

+5

All Articles