我是 Hive 新手。
我已经在 Hive 中创建了一个数据库,默认情况下该数据库是在 Hive 仓库中创建的。当我对 Hive Warehouse 运行 -ls 时,我能够看到创建的数据库 practice.db。
用于创建数据库的查询:
create database practice
COMMENT 'Holds all practice tables';
我在 Hive 中创建了另一个数据库。当我针对创建数据库的路径运行 -ls 命令时,看不到 practice_first.db。
用于创建数据库的查询:
create database practice_first
COMMENT 'Holds all practice tables'
LOCATION '/somepath in hdfs here';
即使我检查了 Hive 仓库 practice_first.db 也没有在 Hive 仓库中。
当我运行 show database 时,我能够在数据库列表中看到 practice_first 数据库。
Hive 创建 practice_first.db 的任何建议。
提前致谢。
最佳答案
刚刚测试以确保它应该在没有添加任何表格的情况下出现,并且确实如此。创建后尝试在数据库上使用 describe 来验证路径:
hive> create database test1 COMMENT 'testing' LOCATION '/user/testuser/test1.db';
OK
Time taken: 0.63 seconds
hive> describe database test1;
OK
test1 testing hdfs://nameserviceHA/user/testuser/test1.db testuser USER
Time taken: 0.183 seconds, Fetched: 1 row(s)
hive> exit;
$ hadoop fs -ls /user/testuser/ | grep test
drwxr-xr-x - testuser testgrp 0 2015-02-12 15:43 /user/testuser/test1.db
对默认位置执行相同操作将自动使用 .db 扩展名命名目录。此外,在这种情况下,组似乎是配置单元而不是用户组:
hive> drop database test1;
OK
Time taken: 0.379 seconds
hive> create database test1 COMMENT 'testing'; OK
Time taken: 0.319 seconds
hive> describe database test1;
OK
test1 testing hdfs://nameserviceHA/user/hive/warehouse/test1.db testuser USER
Time taken: 0.263 seconds, Fetched: 1 row(s)
hive> exit;
$ hadoop fs -ls /user/hive/warehouse | grep test1
drwxrwxrwt - testuser hive 0 2015-02-12 15:53 /user/hive/warehouse/test1.db
关于hadoop - 无法在指定位置的配置单元中查看创建的数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28426921/