All Products
Search
Document Center

ApsaraDB for HBase:HBase Shell

Last Updated:Mar 28, 2026

HBase Shell is an interactive command-line interface for managing data in ApsaraDB for HBase. Use it to create and configure tables, insert and query data, and delete tables.

Prerequisites

Before you begin, ensure that you have:

  • An ApsaraDB for HBase instance (Standard Edition or Performance-enhanced Edition)

  • Shell access to the instance node

For connection setup, see:

Start and exit HBase Shell

Start HBase Shell from the instance node:

$ bin/hbase shell
hbase(main):001:0>

To view available commands and usage, run:

hbase(main):001:0> help

To exit, run:

hbase(main):001:0> quit

Command reference

HBase Shell supports two categories of commands. For the full command reference, see The Apache HBase Shell.

Data definition language (DDL)

CommandDescription
createCreates a table
listLists all tables
describeShows table details and configuration
alterModifies a table or column family
existsChecks whether a table exists
disableDisables a table
is_disabledChecks whether a table is disabled
enableEnables a table
is_enabledChecks whether a table is enabled
dropDeletes a table

Data manipulation language (DML)

CommandDescription
putWrites a value to a cell in a specified row and column
getReads a single row or cell
scanScans a table and returns multiple rows
countCounts the rows in a table
deleteDeletes a specific cell value
deleteallDeletes all cells in a row
truncateClears all data in a table by disabling, dropping, and re-creating it. Regions are not preserved.
truncate_preserveClears all data in a table by disabling, dropping, and re-creating it. Regions from the original table are preserved.

Basic operations

Create a table

Use create with the table name and at least one column family name:

hbase(main):001:0> create 'test', 'cf'

List tables

hbase(main):003:0> list

Filter by name or regular expression:

hbase(main):004:0> list 'abc.*'
hbase(main):005:0> list 'test'

Insert data

Use put to write a value. Each put targets a specific table, row key, column (in family:qualifier format), and value:

hbase(main):006:0> put 'test', 'row1', 'cf:a', 'value1'
hbase(main):007:0> put 'test', 'row2', 'cf:b', 'value2'
hbase(main):008:0> put 'test', 'row3', 'cf:c', 'value3'

Scan a table

scan returns all rows in a table:

hbase(main):009:0> scan 'test'
ROW                     COLUMN+CELL
 row1                   column=cf:a, timestamp=1421762485768, value=value1
 row2                   column=cf:b, timestamp=1421762491785, value=value2
 row3                   column=cf:c, timestamp=1421762496210, value=value3
3 row(s) in 0.0230 seconds

For single-row lookups, use get instead — it is faster than scan for retrieving individual records.

Read a single row

hbase(main):010:0> get 'test', 'row1'
COLUMN              CELL
 cf:a               timestamp=1421762485768, value=value1
1 row(s) in 0.0350 seconds

Disable and enable a table

Disable a table before deleting it or changing its settings:

hbase(main):012:0> disable 'test'
hbase(main):013:0> enable 'test'

Delete a table

A table must be disabled before you can drop it:

hbase(main):014:0> disable 'test'
hbase(main):015:0> drop 'test'
Warning

drop permanently deletes the table and all its data. This action cannot be undone.

Configure tables with alter

Use alter to modify column family settings on an existing table.

Set the major compaction period

The major compaction period is measured in milliseconds. The default is 7 days. Set to 0 to disable scheduled major compactions.

hbase(main):001:0> alter 'test', CONFIGURATION => {'hbase.hregion.majorcompaction' => 300000}
Note

Avoid changing this setting unless your workload specifically requires it.

Set data compression

For details on supported compression formats, see Data compression and encoding.

hbase(main):002:0> alter 'test', NAME => 'cf', COMPRESSION => 'SNAPPY'

Set block encoding

hbase(main):003:0> alter 'test', NAME => 'cf', DATA_BLOCK_ENCODING => 'DIFF'

Set the time to live (TTL)

TTL is measured in seconds. Data older than the TTL is automatically deleted. The following example sets a 30-day TTL (2,592,000 seconds):

hbase(main):004:0> alter 'test', NAME => 'cf', TTL => 2592000

Pre-split a table into regions

Pre-splitting distributes data evenly across regions from the start. See Pre-split.

What's next