Pergunta

Is there a way to change the database's table in hive or Hcatalog?

For instance, I have the table foo in the database default, and I want to put this table in the database bar. I try this, but it doesn't work:

ALTER TABLE foo RENAME TO bar.foo

Thanks in advance

Foi útil?

Solução

AFAIK there is no way in HiveQL to do this. A ticket was raised long back though. But the issue is still open.

An alternate could be to use the EXPORT/IMPORT feature provided by Hive. With this feature we can export the data of a table to a HDFS file along with the metadata using the EXPORT command. The data is stored in JSON format. Data once exported this way could be imported back to another database (even another hive instance) using the IMPORT command.

More on this can be found on the IMPORT/EXPORT MANUAL.

HTH

Outras dicas

thanks for your response. I found an other mean to change the database

USE db1; CREATE TABLE db2.foo like foo

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top