简体   繁体   English

将配置单元外部表更改为同一数据库中的内部表也会从另一个表中删除数据

[英]changing hive external table to internal table in the same database also drops the data from the another table

I have been trying to drop a hive external table using the statement 我一直在尝试使用以下语句删除配置单元外部表

alter table $tableName set tblproperties('EXTERNAL' = 'FALSE'); 修改表$ tableName set tblproperties('EXTERNAL'='FALSE');

after I pass these properties and do a 在我传递这些属性并执行

DROP TABLE TABLENAME; DROP TABLE TABLENAME;

this command also drops the data from the other hive tables in that database. 此命令还将删除该数据库中其他配置单元表中的数据。

Please can anyone suggest me why is it doing so? 请有人能建议我为什么这样做吗? also if there is any way where we can only delete one external table which is mentioned without loosing the other data. 如果有什么办法,我们只能删除提到的一个外部表,而不丢失其他数据。

ALTER TABLE TABLENAME set tblproperties('EXTERNAL' = 'FALSE');
 drop table tablename;

When you drop managed table in Hive, its location with data files also gets dropped. 当您将托管表放在Hive中时,其与数据文件的位置也会被删除。 And technically possible to create many tables, both managed and external on top of the same location, see this answer So, such scenario is quite possible. 从技术上讲,可以在同一位置上创建许多表,包括托管表和外部表,请参见此答案 Some other table created with the same location will be emptied as well. 在相同位置创建的其他一些表也将被清空。 Actually, data and table in Hive are loosely connected things. 实际上,Hive中的数据和表是松散连接的东西。 Table in Hive is a metastore information about location, schema, SerDe, statistics, access privileges, etc. And data is being stored in HDFS/S3 or other compatible filesystem. Hive中的Table是有关位置,架构,SerDe,统计信息,访问权限等的元存储信息。数据正在存储在HDFS / S3或其他兼容的文件系统中。 You can use some other means to drop data or load data, like hadoop fs -rm command, not only managed table in Hive. 您可以使用其他方式删除数据或加载数据,例如hadoop fs -rm命令,不仅限于Hive中的托管表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM