Section.12.135. Prepare-hr-database-with-employees-table

As part of this topic we sag how to create database and then table employees to write queries

against it. We will be primarily employees for Windowing Functions in Hive.

• Create database YOUR-OS-USERNAME-hr

• Create table employees using it as delimiter

• Load data from /data/hr_db/employees into newly created table

• Validate by running simple select query

Here is the gist for preparing the dataset.

https://gist.github.com/dgadiraju/294b35b876f31efbe2437c3e92611d76

CREATE DATABASE training_hr;

USE training_hr;

CREATE TABLE employees (
  employee_id     int,
  first_name      varchar(20),
  last_name       varchar(25),
  email           varchar(25),
  phone_number    varchar(20),
  hire_date       date,
  job_id          varchar(10),
  salary          decimal(8,2),
  commission_pct  decimal(2,2),
  manager_id      int,
  department_id   int
) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';

LOAD DATA LOCAL INPATH '/data/hr_db/employees' INTO TABLE employees;

SET hive.cli.print.header=true;

SELECT * FROM employees LIMIT 30;

Share this post