Hive修改数据库(如何强制删除)

1.修改数据库

用户可以使用 ALTER DATABASE 命令为某个数据库的 DBPROPERTIES 设置键-值对属性值,来描述这个数据库的属性信息。

hive (default)> alter database db_hive set dbproperties('createtime'='20170830');

在hive中查看修改结果

hive> desc database extended db_hive;
db_name comment location owner_name owner_type parameters db_hive hdfs://hadoop102:9820/user/hive/warehouse/db_hive.db atguigu USER {createtime=20170830} 

2.删除数据库

1)删除数据库

hive>drop database db_hive2;

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

hive> drop database db_hive;
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;

猜你喜欢

转载自blog.csdn.net/CharlesCFA/article/details/113850722