1. 程式人生 > >Hive 刪除包含表的資料庫

Hive 刪除包含表的資料庫

當刪除一個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)