Hive 删除包含表的数据库

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yulei_qq/article/details/82216230

当删除一个hive 数据库时,若该 数据库时包含表,则会提示不能删除。

hive> drop  database test;
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. 
InvalidOperationException(message:Database test is not empty. One or more tables exist.)

此时,用户要么先删除数据库中的表,要么再删除数据库;要么在删除命令的最后面加上关键字CASCADE ,这样可以使hive自行先删除数据库中的表;

hive> DROP DATABASE TEST CASCADE;
OK
Time taken: 2.499 seconds
hive> show databases;
OK
default
ts
Time taken: 0.025 seconds, Fetched: 2 row(s)

猜你喜欢

转载自blog.csdn.net/yulei_qq/article/details/82216230
今日推荐