1.数据库
1.1 创建数据库
在 HDFS 上的默认存储路径是/user/hive/warehouse/*.db
create database if not exists Test;
1.2 创建指定HDFS上的位置
CREATE database if not exists Testother location '/20220421.db';
1.3 修改数据库
使用 ALTER DATABASE 命令为某个数据库的 DBPROPERTIES 设置键-值对属性值,来描述这个数据库的属性信息。数据库的其 他元数据信息都是不可更改的,包括数据库名和数据库所在的目录位置
查看数据库的描述:
describe database Testother ;
desc database Testother ;
输出结果:
也可以使用,下面还能看到参数信息
desc database extended Testother ;
对数据数据库信息进行修改
ALTER database Testother set dbproperties('createtime'='20220422');
重新查看输出如下:
1.4 查询数据库
1.4.1 显示数据库:
show databases;
输出:
1.4.2 过滤显示数据库:
使用通配符查询
show databases like "hive*";
输出结果:
1.4.3 显示数据库信息
describe database Testother ;
desc database Testother ;
1.4.4 详细显示数据库信息
describe database extended Testother ;
desc database extended Testother ;
1.5 切换数据库
use hive_test_one ;
1.6 删除数据库
1.6.1 删除空数据库
drop database db_hive2;
1.6.2 数据库不存在的时候
drop database if exists db_hive2;
1.6.3 强制删除数据库
drop database db_hive cascade;