Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Override Hive Default Path

avatar
Expert Contributor

Hi Hive Users,

 

I have created a Hive database by overrrinding the defailt path as follows,

SQL:

Create database diff location '/user/cloudera/sat';

 

After creating this databse, I tried to access this path to see wether it's created a .db folder , but I don't see anything with this name there. Even I created a table in this database and I only see the new folder with name as test.

 

Not sure why its not crated diff.db folder in this path. Please refer the attached screen shots for more details. Please let me know if i am missing anything here.

 

Screen Shot 2017-06-04 at 9.32.57 AM.pngScreen Shot 2017-06-04 at 9.37.42 AM.pngScreen Shot 2017-06-04 at 9.38.27 AM.pngScreen Shot 2017-06-04 at 9.38.51 AM.png

1 ACCEPTED SOLUTION

avatar
Super Collaborator

>> why don't it it creates folder with <dbname>.db folder  when you pass the location to create a database(overriding the default path) ?

 

Because that is how hive works when you provide the path.

 

When you specify the path it uses this path. It's not adding a sub folder to the path you have provided.

It assumes you have provided the path you want to use exactly.

View solution in original post

4 REPLIES 4

avatar
Expert Contributor

Hi,

Could anyone please let me know on this? Thanks.

avatar
Super Collaborator

Why do you expect to see a *.db folder if you don't specify it yourself ? This is not "how it works".

 

The following command sets the root dir of the database "diff" to "/user/cloudera/sat" :

 

Create database diff location '/user/cloudera/sat';

 This will not create a folder "diff.db" inside "sat".

 

If this is what you want then use the following command :

Create database diff location '/user/cloudera/sat/diff.db';

 

 

 

avatar
Expert Contributor

When I create a database without passing the location, then it will create that database in default location with <dbname>/db

ex:

hive> CREATE DATABASE Override1;
OK
Time taken: 0.06 seconds

it will create a Override1.db folder in the default path as

[cloudera@quickstart ~]$ hadoop fs -ls /user/hive/warehouse
Found 1item
drwxrwxrwx   - cloudera supergroup          0 2017-06-09 14:46 /user/hive/warehouse/override1.db
[cloudera@quickstart ~]$ 

why don't it it creates folder with <dbname>.db folder  when you pass the location to create a database(overriding the default path) ?

avatar
Super Collaborator

>> why don't it it creates folder with <dbname>.db folder  when you pass the location to create a database(overriding the default path) ?

 

Because that is how hive works when you provide the path.

 

When you specify the path it uses this path. It's not adding a sub folder to the path you have provided.

It assumes you have provided the path you want to use exactly.