Table Management Commands

The Table Management command supports programmers to create tables and schema with rows and column families. Will study one by one in this session.

1. Create                                                                  

Create command used to creates a table along with column family in hbase.

Syntax

hbase> create ‘<tablename>’, ‘<columnfamilyname>’

Example

In this example will create table name called “beyondemp” with two column families like “personal data” and “professional data”.

hbase(main)> create ‘beyondemp’, ‘personal data’, ‘professional data’

2. List

List command helps to display whatever the tables present or verify the created table in Hbase.

Example

Here will verify the above created table using list command.

hbase(main)>list

3. Describe

Describe command provides the description of a table like table name with column families, associated filters, and versions.

Syntax

hbase>describe <table name>

Example

In this example we are getting information about the “beyondemp” table.

hbase(main)> describe ‘beyondemp’

4. Disable

Using disable command we can disables a table for modification or deletion operation of the existing table.

Syntax

hbase>disable ‘<tablename>’

Example

Support I need to delete the above table before deleting the above table firstly we have to disable the table.

hbase(main)> disable ‘beyondemp’

5. Disable_all

Using disable_all command we can delete all the tables matching the given regex.

Syntax

hbase>disable_all ‘<matching text>’

Example

In this example we are deleting the entire table matching with the letter “b”

hbase(main)> disable_all ‘b.*’

6. Is_disabled

This command is used to verify whether a table is disabled or not.

Syntax

hbase>is_disabled ‘<tablename>’

Example

In this example we are cross verifying that table is disabled or not.

hbase(main)> is_disabled ‘beyondemp’

7. Enable

Enable command is used to enables the entire disable table. We can reuse the disable table using this command.

Syntax

hbase>enable ‘<tablename>’

Example

In the previous example we have disable the “beyondemp” table, now again I have to reuse that table in that case we can use enable command.

hbase(main)> enable ‘beyondemp’

8. Is_enabled          

This command is used to verify whether the named table is enabled or not.

Syntax

hbase>is_enabled ‘tablename’

Example

In this example will cross verify that “beyondemp” table is enabled or not using is_enabled command.

hbase(main)> is_enabled ‘beyondemp’

9. show_filters

Show_filter command used to display the information about the filters present in HBase For example fix Filter, Timestamps Filter, Page Filter, Family Filter, etc.

Example

In this example we are displaying all the present filter of hbase.

hbase(main)>show_filters

10. Drop

Drop command is used to delete table from HBase.

Note: Before deleting table first we need to disable the table.

Syntax

hbase>drop ‘<table name>’

Example

In this example we are deleting the “beyondemp” table from the hbase, first we need to disable then we can delete the table.

hbase(main)> disable ‘beyondemp’

hbase(main)> drop ‘beyondemp’

11. Drop_all

Using this command we can drops the tables matching the ‘regex’ given in the command.

Syntax

Hbase>drop_all ‘<regex>’

Example

In this example will delete all the tables starting with the text “beyond”

hbase(main)> drop_all ‘b.*’

12. Alter

Using alter command we can alter single, multiple column family names and deleting column family names from table.

Example

In this example will see the different ways of altering the schema.

1. Here we are changing column family name personal data to personal data1

hbase> alter ‘beyondemp’, NAME=>’personal data1′, VERSIONS=>5

2. In this case I am adding new columns to our existing table “beyondemp”.

hbase> alter ‘beyondemp’, ‘personal data1’, {NAME => ‘first_name’, IN_MEMORY => true}, {NAME => ‘Last_name’, VERSIONS => 5}

3. In this case will see how to delete column family from the table.

hbase> alter ‘beyondemp’, { NAME => ‘personal data1’, VERSIONS => 3 },{ MAX_FILESIZE => ‘134217728’ }, { METHOD => ‘delete’}

13. Alter_status

Alter_status command used to get the updates of the modified command in hbase.

i.e it include information like the number of regions of the table that have received the updated schema.

Example

In this example will get the alter information of the schema.

hbase>alter_status ‘beyondemp’

“That’s all about the Table Management Commands in Hbase”.