Yes without an external table keyword, Hive will think that he needs to
manage the data and if you drop the table, data will also be dropped.


Probably, the first time your table is not dropped because you have a typo
error in your table name.


hive> drop table *preson*;

OK

Time taken: 0.184 seconds


Regards,

Tanvi Thacker

On Thu, Aug 9, 2018 at 4:06 AM xujund...@163.com <xujund...@163.com> wrote:

> Hi Apache org:
>     Recently I found a very interesting question, I don't know is a bug
> or design flaws.
>     最近我发现了一个有趣的问题,不知道是bug还是设计的漏洞。
>     When creating internal table, plus the location keyword and path.At
> this time to create table can delete the original data, also can appear
> first data, the following is my test data:
>     当创建内部表的时候,如果及爱上location关键字以及路径,此时创建的表既能删除数据,也能提前有数据,以下是我的测试数据:
>     Before the data into the data/person directory, and the data content
> is as follows:
>     将数据提前传入HDFS的data/person目录下,数据内容如下:
>
> 1.0|张三|20.0|男|未知|0
>
> 2.0|李四|25.0|男|河北|0
>
> 3.0|张飞|30.0|男|河北|0
>
> 4.0|关羽|35.0|男|山东|0
>
> 5.0|小乔|38.0|女|浙江|0
>
> 6.0|刘备|40.0|男|成都|0
>
> 7.0|小李|29.0|男|江南|0
>
> create table:
>
> 创建表:
>
> *hive> create table person(id string,name string,age string,gender
> string,address string,test int) row format delimited fields terminated by
> '|' location 'hdfs://192.168.75.150:9000/data/person
> <http://192.168.75.150:9000/data/person>';*
>
> *OK*
>
> *Time taken: 0.148 seconds*
>
> *hive> select * from person;*
>
> *OK*
>
> *1.0* *张三* *20.0* *男* *未知* *0*
>
> *2.0* *李四* *25.0* *男* *河北* *0*
>
> *3.0* *张飞* *30.0* *男* *河北* *0*
>
> *4.0* *关羽* *35.0* *男* *山东* *0*
>
> *5.0* *小乔* *38.0* *女* *浙江* *0*
>
> *6.0* *刘备* *40.0* *男* *成都* *0*
>
> *7.0* *小李* *29.0* *男* *江南* *0*
>
> *Time taken: 0.141 seconds, Fetched: 7 row(s)*
>
> *hive> *
>
> Creates a data at this time the interior of the outer table, the table
> also allows the first data, displaying the data, is I uploaded to the data
> in advance/person in the directory, perfect internal table shows the
> external data.
>
> 此时就创建了一个数据外置的内部表,这个表也允许先有数据,上面展示的数据,就是我提前上传到data/person目录中的,完美展示了数据外置的内部表。
>
> If you delete this table in a Hive, however, the data will be removed.
>
> 然而如果删除Hive中的这个表的话,数据也会跟着被删除。
>
> Below is the data storage directory:
>
> 下图是数据存放的目录:
>
>
>
> Take a test database directory:
>
> 看一下test数据库的目录:
>
>
>
> No person table directory.
>
> 没有person表的目录。
>
> The next will delete person table to see the changes:
>
> 接下来将删除person表看看目录的变化:
>
> *hive> drop table preson;*
>
> *OK*
>
> *Time taken: 0.184 seconds*
>
> *hive> show tables;*
>
> *OK*
>
> *person*
>
> *promo*
>
> *tab*
>
> *Time taken: 0.222 seconds, Fetched: 3 row(s)*
>
> *hive> drop table person;*
>
> *OK*
>
> *Time taken: 0.189 seconds*
>
> *hive> show tables;*
>
> *OK*
>
> *promo*
>
> *tab*
>
> *Time taken: 0.076 seconds, Fetched: 2 row(s)*
>
> *hive> *
>
> The first time to delete didn't succeed, don't know which, the second
> deleted successfully, the following is the directory structure:
>
> 第一遍删除竟然没有成功,不知道闹哪样,第二次删除成功,下面是目录结构:
>
>
>
> The data directory is empty, the person does not exist in the folder.
>
> data目录空了,person文件夹也不存在了。
>
> In my study, don't realize this, so I don't know this is normal or
> abnormal, and if this is normal case, want to view the list of database,
> combined with the identity of the internal and external tables, so it is
> not easy to remove by mistake.Now the situation is easy to appear
> prematurely removed!
>
>
> 在我的学习和认知中,没有接触到这块的内容,也不知道这是正常情况还是异常情况,如果是正常情况,希望在查看数据库表的列表时能够标识出内部表和外部表,现在没有标识,很容易造成误操作,导致数据丢失。
>
> Also, under table if missed when external keyword, easy to cause the wrong
> operation table, is the result of the above situation.
>
> 另外,如果在创建表的时候,如果不小心,漏掉了external关键字,那么很容易就创建出了这个表,然后就会造成上面的问题。
>
> English level is limited, don't understand the place looked understanding,
> enclose the original in Chinese.
>
> 抱歉,英语水平有限,这里也附上中文。
>
>
> xujunda徐俊达
>
> 2018.08.09
> ------------------------------
> xujund...@163.com
>

Reply via email to