Skip to content
Zhamri Che Ani edited this page Nov 7, 2023 · 6 revisions

Data Manipulation Language

put - Puts a cell value at a specified column in a specified row in a particular table.

get - Fetches the contents of row or a cell.

delete - Deletes a cell value in a table.

deleteall - Deletes all the cells in a given row.

scan - Scans and returns the table data.

count - Counts and returns the number of rows in a table.

truncate - Disables, drops, and recreates a specified table.

Java client API - Prior to all the above commands, Java provides a client API to achieve DML functionalities, CRUD (Create Retrieve Update Delete) operations and more through programming, under org.apache.hadoop.hbase.client package. HTable Put and Get are the important classes in this package.

Example (HBase is case sensitive)

// put 'table_name', 'row_key', 'column_family:qualifier', 'value'
put 'Car', '1', 'details:made', 'Toyota'
put 'Car', '1', 'details:model', 'Corolla'
put 'Car', '1', 'info:year', '2020'

put 'Car', 'row2', 'details:made', 'Honda'
put 'Car', 'row2', 'details:model', 'Civic'
put 'Car', 'row2', 'info:year', '2018'

// scan 'table_name', {OPTIONS}
hbase> scan 'Car'
hbase> scan 'Car', {LIMIT => 4}
hbase> scan 'Car', {COLUMNS => ['details:model', 'info:year']}
hbase> scan 'Car', {COLUMNS => ['details:model', 'info:year'], LIMIT => 10, STARTROW => 'row2'}
hbase> scan 'Car', {COLUMNS => ['details:make', 'details:model'], LIMIT => 10, STARTROW => '001', STOPROW => '010'}

// get 'table_name', 'row_key'
hbase> get 'Car', '1'
hbase> get 'Car', 'row2'
hbase> get 'Car', 'row2', {COLUMNS => ['details:made', 'details:model']}

// count 'table_name'
hbase> count 'Car'

// delete 'table_name', 'row_key', 'column_family:column', 'timestamp'
hbase> delete 'Car', 'row2', 'details:made'

// deleteall 'table_name', 'row_key', 'column_family'
hbase> deleteall 'Car', 'row2'
hbase> deleteall 'Car', 'row2', 'details'

// truncate 'table_name'
hbase> truncate 'Car'

Note:

The 'truncate' command will perform the following actions:

  1. Disable the Car table if it is not already disabled.
  2. Drop the Car table, which deletes all of its data and metadata.
  3. Create a new table with the same name Car and the same column family structure.

References:

  1. https://www.tutorialspoint.com/hbase/hbase_shell.htm

Clone this wiki locally