Вы находитесь на странице: 1из 15

Listing the Databases (only default database):

Creating a new database

Listing the tables in the new database:

Note :use default will take you to default database


If we create a table in this new database created, a directory for the
new database will be created in the default hive warehouse path and
in turn a sub directory for each table within it (cmptbl1 is the table
created in vema database)

Creating Managed table:

Loading managed table in Local mode:

Input:

Load:

Querying table:

Default hive warehouse path:

Loading the same file again:

Load:

Querying table:
6+6 = 12 records

Default hive warehouse path

Note: when we try to load the table again using the same input file, hive will only
rename the file accordingly in the default warehouse path.

Delete one file from default hive warehouse path:

Querying table
(12 6 = 6 records)

Querying table using Like operator:

Loading Managed table in HDFS mode:

Input:

Load :

Note : when we load the data in HDFS mode, internally it is move from input
HDFS path to local hive warehouse path (which is also HDFS). So the file in
source path will be removed

Querying table:

Loading same file again:

Input:
Place the file into the same HDFS input path once again:

Load :

Note: when we execute the move command from source HDFS location to target
HDFS location, and the same file name is already existing in target HDFS location,
we will get an error

Also, the file name in input HDFS path will be renamed as a result of the above load
and the user has an option to load the renamed file

File will be removed from source path:

Querying table:

Default Hive Warehouse Path:

Deleting one file from Default Hive warehouse path:

Querying table:

Creating External table:

Output (External) HDFS directory is empty

Loading External table in Local mode:

Input:

Load:

Querying:

External HDFS path:

Loading same file again in Local mode:

Load

Querying

External HDFS Path:

Deleting one of the file from output HDFS Path:

Querying data from table:

Loading External table in HDFS mode:


Input:

Load:

Querying table:

Input HDFS Path (File at source will be deleted):


External HDFS Path:

Loading same file again in External table in HDFS mode:


Input (place the file once again):

Load:
Move will fail in this case (Input HDFS to Output HDFS, and output HDFS already
having the file) and
as the result of the move operation, the file name in Input HDFS path will be
renamed

Load the renamed file to the table

Querying the table:

Output HDFS Path:

File will be deleted from Source HDFS Path

Deleting one file from output HDFS Path:


Querying the table:

DROPPING tables:

Default hive ware house path (Managed table)

Output HDFS Path (External table)

Drop Managed table:

Drop External table:

Default hive ware house path (Managed table):


Note: Will be removed when the table is dropped

Output HDFS Path (External table):

Note : Will be retained even after dropping table.

Loading External table at the time of creation only:


Place a file in a input HDFS path

Creation

No explicit load is required in this case.


Querying table:

Input/Output HDFS Path:

Add another file to HDFS path:

Data will be reflected in table also: