The Hive concept of a database is essentially just a
catalog or namespace of tables. However, they are very useful for larger
clusters with multiple teams and users, as a way of avoiding table name
collisions. It’s also common to use databases to organize production tables
into logical groups.
If you don’t specify a database, the default database is used.
Listing the already existing databases in hive:-
Query- Show
databases;
Creating a database:-
Query- Create
database if not exists database1;
If not exists is an optional keyword used to check
whether the database already exists or not.
To override the use of default database:-
Query- Use
hive1;
To view the properties of a database:-
To view the location and other properties of a database,
describe command can be used.
Query- Describe
database database1;
Drop Database:-
Query- Drop
database database1;
Hive will create a directory for each database. Tables
in that database will be stored in
Subdirectories of the database directory.
No comments:
Post a Comment