Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transferring hive table from one database to another

Tags:

hive

hiveql

I need to move a hive table from one database to another. How can I do that?

like image 848
user2942227 Avatar asked Apr 21 '14 21:04

user2942227


2 Answers

Since 0.14, you can use following statement to move table from one database to another in the same metastore:

use old_database; alter table table_a rename to new_database.table_a 

The above statements will also move the table data on hdfs if table_a is a managed table.

like image 99
Jay Avatar answered Sep 22 '22 04:09

Jay


create external table new_db.table like old_db.table location '(path of file in hdfs file)';

if you have partition in table then you have to add partition in new_db.table.

like image 28
bunty Avatar answered Sep 20 '22 04:09

bunty