hive数据库操作——hive命令行

hive数据库操作——hive命令行

本文主要介绍通过hive命令行对hive数据库进行操作。

好,下面上货。
1、显示所有数据库
show databases;
hive数据库操作——hive命令行

模糊匹配数据库名称
show databases like 'd*';
hive数据库操作——hive命令行

2、数据库新增
create database if not exists xytestdatabase;
hive数据库操作——hive命令行

新增数据库后,能够在hdfs中查询到数据库的位置
hive数据库操作——hive命令行
hive数据库操作——hive命令行

3、查看数据库的具体信息
describe database xytestdatabase;
hive数据库操作——hive命令行

或者使用更详细的方式。
describe database extended xytestdatabase;
hive数据库操作——hive命令行

4、删除数据库
drop database if exists xytestdatabase;
hive数据库操作——hive命令行


删除数据库的时候有一点需要注意,如果数据库中是有表的,那么是不允许删除的,如果想要删除,那么想要使用如下命令:
drop database if exists xytestdatabase cascade;

注意:在hive中是不能对数据库进行修改的,无论是数据的名称,还是数据库的存储路径都是不能修改的。