ITechShree-Data-Analytics-Technologies

Hbase commands


 

Like rdbms schema ,hbase has namespace.

If no namespace is defined all created hbase tables are in default namespace.

 

 

1.Create namespace in Hbase:

 

create_namespace '<namespace name>'

 Example:

hbase(main):003:0> create_namespace 'student_management'                                                                              

0 row(s) in 0.0290 seconds  

 

2.Creating table in hbase

 create '<tablename>', '<columnfamilyname>'

 

 If namespace is defined then command:

 

create <namespace:tablename>, <columnfamilyname>

 

if there is more column family those should be declared here separed by comma(,).

 

Example:

hbase(main):004:0> create 'student_management:student','personal_details','marks_details'                                             

0 row(s) in 1.2180 seconds                                                                                                            

                                                                                                                                      

=> Hbase::Table - student_management:student 

 

 

3. listing out all tables

 

list

 

it will display all the tables that are present or created in HBase

 

4.Describe:

describe '<table name>'

 

 example:

ITechshree:Hbase describe command





3.insert data into table:

 

command to insert data into hbase table:

 

put  '<hbase tatble name>', '<row_key>','<column_family_name:column_name>','<column_value>'

 

example:

 

put 'student_management:student','1','personal_details:name','rohit'

 

put 'student_management:student','1','personal_details:age',16

 

put 'student_management:student','1','marks_details:math',78

put 'student_management:student','1','marks_details:eng',80

 

put 'student_management:student','2','personal_details:name','rita'

 

put 'student_management:student','2','personal_details:age',15

 

put 'student_management:student','2','marks_details:math',83

put 'student_management:student','2','marks_details:eng',90

ITechShree:Hbase put command






4.To fetch details from hbase table:

 

get <'tablename'>, <'rowname'>, <other  parameters>

 

example:

ITechShree:Hbase get command
 







5.alter table:

It is used to  add or remove column  and  modify the table properties in hbase table

 

command to update versions :

alter <tablename>, NAME=>’<column familyname>’, VERSIONS=><new version no>

 

example

alter 'student_management:student' ,NAME =>'personal_details',VERSIONS =>2 

 

ITechshree:Hbase alter command to add version



To delete and add column family:

ITechShree: Hbase alter command to add and delete column family






Note: syntax for method should be followed to update regions using alter command

 

To enable snappy compression on the existing HBase column family:

 

ITechShree: Hbase alter command to enable compression




6.Scan command:

 

This command scans entire table and displays the table contents. 

 

scan <'tablename'>, {Optional parameters}

 

example:

ITechShree: Hbase scan command





7. Delete command:

This command will delete cell value at defined table of row or column. 

 

delete <'tablename'>,<'row name'>,<'column name'>

 

example:


ITechShree:Hbase scan command



8.Truncate:

This command will truncate the records of hbase table but schema will be present.

 It performs 3 functions-

Disables table if it already presents

Drops table if it already presents

Recreates the mentioned table

 

 truncate <tablename>

 example:


ITechShree:Hbase truncate command




9.Drop

 To drop the table present in HBase, first we have to disable it .


drop <'table name'>

example:

ITechShree: Hbase drop command






same like disable , enable command is present which is used to enable hbase table

 Hope you got idea  about the basic commands in  Hbase  and how to run  in hbase shell.

 Please   follow for more updates.




Post a Comment

0 Comments