Hive question: managed table/external table

Hi guys,

to be simple, in the real exam, how do i know if i should create a managed table or external table ? Even i see the location is specified to HDFS, save to user/cert/problem3, the fact is that we can specify path for both managed table and external table. what should i pay attention on? i see no one else has the similar issue, but i am confusing. exmaple is below:

create table example1(
state string,
id int
)
stored as avro
location ‘/user/cert/problem3’

create external table example2(
state string,
id int
)
stored as avro
location ‘/user/cert/problem3’

Thanks!

In hive manage table location is optional. But in external table location is mandatory. If you drop hive manage table it will drop/delete the data in location with the metadata of table. But if you drop the external table then only the structure of table i.e. metadata will be deleted but the data in the location will still be there.
In managed table, if you do not give location, you can load data using load data or insert command in the table.

You have to pay attention “Not to delete or loose the given HDFS Data at any cost”.

Few problems explicitly mentioned what type of tables should be created and also you need to choose table type appropriately…

If you use LOAD statement then your source data would be lost after the successful load. So to avoid that its better to go with temporary external table to insert into the Target Table.

thank you for your reply.

thanks for your response.