黑猴子的家:Hive 删除数据库

1、删除空数据库

hive>drop database db_hive2;

2、如果删除的数据库不存在,最好采用 if exists判断数据库是否存在

hive> drop database db_hive2;
FAILED: SemanticException [Error 10072]: Database does not exist: db_hive

标准写法

hive> drop database if exists db_hive2;

3、如果数据库不为空,可以采用cascade命令,强制删除

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

强制删除

hive> drop database db_hive cascade;

你可能感兴趣的:(黑猴子的家:Hive 删除数据库)