0% found this document useful (0 votes)
10 views11 pages

Hbase Shell Commands

The document provides a comprehensive guide on using HBase shell commands for creating tables, inserting data, and retrieving information. It includes multiple assignments that require creating various tables such as 'students', 'employees', 'products', and more, each with specific data requirements. Additionally, it outlines basic commands like 'create', 'put', 'get', and 'scan' for managing HBase tables.

Uploaded by

pathakpritee20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views11 pages

Hbase Shell Commands

The document provides a comprehensive guide on using HBase shell commands for creating tables, inserting data, and retrieving information. It includes multiple assignments that require creating various tables such as 'students', 'employees', 'products', and more, each with specific data requirements. Additionally, it outlines basic commands like 'create', 'put', 'get', and 'scan' for managing HBase tables.

Uploaded by

pathakpritee20
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

hbase shell To start hbase shell

hbase version To check Hbase version


list Lists all the table names
Disable ‘tablename’ Disables the table before
deleting it
Enable ‘tablename’ Enables the table
Drop ‘tablename’ delete

Step 1: Start HBase Shell


start the HBase shell by running this command from your terminal:
hbase shell
Step 2: Create the Table
Next, let's create a table called users. We'll define one column family: info for personal
information (like name, email),
create 'users', 'info’
Step 3: Insert (Put) Values into the Table
Now, let's insert some data into the table users using the put command. We'll insert values
for different rows and columns.
1. Inserting data for row1:

put 'users', 'row1', 'info:name', 'John Doe'


put 'users', 'row1', 'info:email', '[email protected]'
2. Inserting data for row2:

put 'users', 'row2', 'info:name', 'Jane Smith'


put 'users', 'row2', 'info:email', '[email protected]'

Step 4: Verify the Data Insertion


You can use the get command to verify that the data has been inserted correctly.
1. To check the data for row1:
get 'users', 'row1'

2. Similarly, to check the data for row2:


get 'users', 'row2'

3. To scan the users table and view all rows, you would use:

scan 'users'

Assignment 1: Create a Table and Insert Data


1. Create a table:
o Create a table called students with a single column family named details.
o The table should store the following information for each student:
 name (student's full name)
 email (student's email address)
 age (student's age)
2. Insert data:
o Insert the following data into the students table:
 For student row1, insert the following information:
 Name: Alice Green
 Email: [email protected]
 Age: 21
 For student row2, insert the following information:
 Name: Bob White
 Email: [email protected]
 Age: 22
3. Verify the data:
o Use the get command to retrieve the data for both row1 and row2 from the
students table.
o Verify that the values you inserted are correctly stored.

Assignment 2: Create a Table and Insert Data


 Create a Table:
 Create a table called employees with a column family named personal_info.
 The table should store the following data for each employee:
o name (employee's name)
o age (employee's age)
o department (employee's department)
 Insert Data:
 Insert the following data into the employees table:
o For row key emp1, insert:
 Name: John Doe
 Age: 30
 Department: HR
o For row key emp2, insert:
 Name: Jane Smith
 Age: 28
 Department: Engineering
Assignment 3: Create a Student Table and Insert Data
1. Create a Table:
o Create a table called students with a column family named info.
o The table should store the following data for each student:
 name (student's name)
 grade (student's grade)
 email (student's email)
2. Insert Data:
o Insert the following data into the students table:
 For row key student1, insert:
 Name: Alice Green
 Grade: A
 Email: [email protected]
 For row key student2, insert:
 Name: Bob White
 Grade: B
 Email: [email protected]

Assignment 4: Create a Product Table and Insert Data


1. Create a Table:
o Create a table called products with a column family named details.
o The table should store the following data for each product:
 product_name (product name)
 category (product category)
 price (product price)
2. Insert Data:
o Insert the following data into the products table:
 For row key product1, insert:
 Product Name: Laptop
 Category: Electronics
 Price: 1000
 For row key product2, insert:
 Product Name: Smartphone
 Category: Electronics
 Price: 600

Assignment 5: Create a Library Table and Insert Data


1. Create a Table:
o Create a table called library with a column family named book_info.
o The table should store the following data for each book:
 title (book title)
 author (book author)
 published_year (year the book was published)
2. Insert Data:
o Insert the following data into the library table:
 For row key book1, insert:
 Title: The Great Gatsby
 Author: F. Scott Fitzgerald
 Published Year: 1925
 For row key book2, insert:
 Title: To Kill a Mockingbird
 Author: Harper Lee
 Published Year: 1960

Assignment 6: Create a Movie Table and Insert Data


1. Create a Table:
o Create a table called movies with a column family named movie_info.
o The table should store the following data for each movie:
 movie_name (name of the movie)
 director (movie's director)
 release_year (year the movie was released)
2. Insert Data:
o Insert the following data into the movies table:
 For row key movie1, insert:
 Movie Name: Inception
 Director: Christopher Nolan
 Release Year: 2010
 For row key movie2, insert:
 Movie Name: Titanic
 Director: James Cameron
 Release Year: 1997

Assignment 7: Create a Company Table and Insert Data


1. Create a Table:
o Create a table called companies with a column family named company_info.
o The table should store the following data for each company:
 company_name (company's name)
 industry (company's industry)
 headquarters (company's headquarters location)
2. Insert Data:
o Insert the following data into the companies table:
 For row key company1, insert:
 Company Name: Tech Corp
 Industry: Technology
 Headquarters: San Francisco
 For row key company2, insert:
 Company Name: HealthPlus
 Industry: Healthcare
 Headquarters: New York

Assignment 8: Create a Vehicle Table and Insert Data


1. Create a Table:
o Create a table called vehicles with a column family named vehicle_info.
o The table should store the following data for each vehicle:
 make (vehicle's make)
 model (vehicle's model)
 year (vehicle's manufacturing year)
2. Insert Data:
o Insert the following data into the vehicles table:
 For row key vehicle1, insert:
 Make: Toyota
 Model: Corolla
 Year: 2020
 For row key vehicle2, insert:
 Make: Ford
 Model: F-150
 Year: 2018
Assignment 9: Create a Customer Table and Insert Data
1. Create a Table:
o Create a table called customers with a column family named customer_info.
o The table should store the following data for each customer:
 customer_name (customer's name)
 address (customer's address)
 phone_number (customer's phone number)
2. Insert Data:
o Insert the following data into the customers table:
 For row key customer1, insert:
 Customer Name: Michael Johnson
 Address: 123 Maple St, Springfield
 Phone Number: 555-1234
 For row key customer2, insert:
 Customer Name: Sarah Lee
 Address: 456 Oak St, Rivertown
 Phone Number: 555-5678

HBase table scenarios, each focusing on basic commands like create, put, get, and scan.

Table 1: School

Question 1: Create a table school with the following column families:

Student_info (to store name, age, and class).

Academic (to store math_marks, science_marks, and english_marks).

1. Insert the following data for a student with row key stu001:

Student_info: name=Alice, age=14, class=8th.

Academic: math_marks=85, science_marks=90, english_marks=88.


2. Retrieve all data for stu001.

3. Retrieve only the academic column family for stu001.

4. Scan the entire table to see all students.

Table 2: Hospital

Question 2: Create a table hospital with the following column families:

Patient_info (to store name, age, and gender).

Medical_history (to store diseases and medications).

1. Insert the following data for a patient with row key pat001:

Patient_info: name=John, age=45, gender=Male.

Medical_history: diseases=Diabetes, medications=Metformin.


2. Insert another patient with row key pat002:

Patient_info: name=Emma, age=34, gender=Female.

Medical_history: diseases=Hypertension, medications=Losartan.

3. Retrieve all data for pat002.

4. Retrieve only the medical_history column family for pat001.

Table 3: Bank

Question 3: Create a table bank with the following column families:

Account_info (to store account_number, account_type).

Transaction_info (to store last_transaction_date, balance).

1. Insert the following data for a customer with row key cust001:

Account_info: account_number=123456789, account_type=Savings.


Transaction_info: last_transaction_date=2025-01-01, balance=1500.

2. Insert another customer with row key cust002:

Account_info: account_number=987654321, account_type=Current.

Transaction_info: last_transaction_date=2025-01-03, balance=3200.

3. Retrieve the balance for cust001.

4. Scan the table to list all customers and their details.

Table 4: E-Commerce

Question 4: Create a table ecommerce with the following column families:

Product_info (to store product_name, category, and price).

Sales_info (to store units_sold, total_revenue).

1. Insert the following data for a product with row key prod001:
Product_info: product_name=Laptop, category=Electronics, price=800.

Sales_info: units_sold=50, total_revenue=40000.

2. Insert another product with row key prod002:

Product_info: product_name=Smartphone, category=Electronics, price=500.

Sales_info: units_sold=100, total_revenue=50000.

3. Retrieve all sales information for prod002.

4. Retrieve the price of prod001.

Table 5: Movie Database

Question 5: Create a table movies with the following column families:

Movie_info (to store title, genre, release_year).

Rating_info (to store imdb_rating, box_office).


1. Insert the following data for a movie with row key mov001:

Movie_info: title=Inception, genre=Sci-Fi, release_year=2010.

Rating_info: imdb_rating=8.8, box_office=830000000.

2. Insert another movie with row key mov002:

Movie_info: title=The Dark Knight, genre=Action, release_year=2008.

Rating_info: imdb_rating=9.0, box_office=1005000000.

3. Retrieve all data for mov001.

4. Scan the table to list all movies and their details.

Deliverables:

1. Commands: Provide the create, put, get, and scan commands for each question.
2. Output: Attach screenshots of HBase shell outputs for all commands.

3. Report: Write a short explanation for each task (optional).

These assignments give students practice with creating tables, inserting values, retrieving data, and
scanning tables, all while working with multiple column families. Let me know if you need additional
variations!

You might also like