无法在指定位置的配置单元中查看已创建的数据库

时间:2015-02-10 08:14:55

标签: hadoop hive hdfs hiveql

我是Hive的新手。

我在Hive中创建了一个数据库,默认情况下,数据库是在Hive仓库中创建的。当我对Hive Warehouse运行-ls时,我能够看到创建的数据库practice.db。

用于创建数据库的查询:

  

创建数据库练习

     

评论'保留所有练习表';

我在Hive中创建了另一个数据库。当我在创建数据库的路径上运行-ls命令时,无法看到practice_first.db。

用于创建数据库的查询:

  

创建数据库practice_first

     

评论'保留所有练习表'

     

此处hdfs中的LOCATION' / somepath';

即使我在Hive仓库中检查,practice_first.db也不在hive仓库中。

当我运行show database时,我能够在数据库列表中看到practice_first数据库。

Hive创建practice_first.db的任何建议。

先谢谢。

3 个答案:

答案 0 :(得分:2)

刚刚经过测试,确保在没有添加任何表格的情况下显示它。创建后尝试在数据库上使用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而不是用户组:

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

答案 1 :(得分:1)

将在LOCATION

指定的路径创建

检查HIVE-1537this

答案 2 :(得分:0)

如果

,您将能够看到 practice_first.db 目录

1)您在默认位置创建数据库。

2)您在CREATE DATABASE语句中的LOCATION中明确提供目录名称为 practice_first.db