-1

I'm having a data in a external table. Now I'm copying the data from external table to a newly created table in a database. What kind of table will be the table in the database? Is it a managed table or external table? I need your help to understand the concept behind this question

Thanks, Madan Mohan S

  • It is not clear what you asked. – Nicolas Henneaux Aug 16 '16 at 07:03
  • I'm having a database named 'db1' in hive which consists of table called emp3 and we have a external table called employees. If I copy my data from employees to emp3(both have same schema), my emp3 will be managed table or external table in hive? – Madan Mohan Aug 16 '16 at 10:21

1 Answers1

0

The hive table get their type "Managed" or "External" at time of their creation, not when data is inserted.

So table employees is external (because it was created using "create External" in DDL and provided location of data file.
The emp is managed table because "external" was NOT used in DDL and also location of data was not needed.

The difference now is, if table employees dropped the data it was reading that was provided in "location" is not deleted. So external table is useful when data is being read by multiple tools i.e pig. If pig script is reading same location, it will still function even though employees table is dropped.

But emp is managed (in other word metadata and data both are managed by hive) so when emp is dropped the data also are deleted. So after dropping it if you check the hive warehouse directory you will no find "emp" hdfs directory anymore.

Sagar Shah
  • 118
  • 4