DDL commands are table management commands which are used to create a table, list table, describe the table, and so on.

Apache HBase supports the below list of DDL commands.

  1. Create Table
  2. List
  3. Describe
  4. Disable
  5. Disable_all
  6. Show_filters
  7. Drop Table
  8. Drop_all
  9. Is_enabled
  10. Alter

Let us see each DDL command in detail.


1. Create Table

Using create table command we can create a table by specifying the table name and column family.

Syntax
hbase(main):006:0> create ‘table name’,’column family’

Here we have created a table ‘employee’ with a two-column family (‘emp_address’,’emp_records’).

Command
hbase(main):006:0> create 'employee','emp_address','emp_records'

Output
create table hbase


2. List

List command is used to display the tables which are present in HBase.

Syntax
hbase(main):006:0> list

Command
hbase(main):006:0> list

Output
hbase list


3. Describe

Describe command is used to display the table name with column families, associated filters, versions, and few more details.

Syntax
hbase(main):030:0> describe 'tablename'

Command
hbase(main):030:0> describe 'employee'

Output
describe hbase


4. Disable

Disable command is used to disable a table. It is used when a table needs to be dropped in that case first we need to disable the table and then we can drop it.

Syntax
hbase(main):031:0> disable 'tablename'

Command
hbase(main):031:0> disable 'employee'

Output
disable hbase


5. Disable_all

Disable_all command is used to disable all tables. It is used when all table needs to be dropped in that case first we need to disable all tables and then we can drop.

Syntax
hbase(main):035:0> disable_all  'matching tablename’

Command
hbase(main):035:0> disable_all 'employee'

Output
disable all hbase


6. Show_filters

Show_filters command is used to display all filters present in HBase such as DependentColumnFilter, KeyOnlyFilter, ColumnCountGetFilter, and so on.

Syntax
hbase(main):036:0> show_filters

Command
hbase(main):036:0> show_filters

Output
show filter hbase


7. Drop_Table

Before performing the “drop” or “delete” table command first we need to disable it and then we can drop or delete a table.

Syntax
hbase(main):038:0> drop ‘table_name’

Command
hbase(main):038:0> drop 'employee'

Output
drop table


8. Drop_all

Drop_all command will drop all tables which are matching in the given regex but before performing the “drop_all” command first we need to disable it.

Syntax
hbase(main):042:0> drop_all 'regex'

Command
hbase(main):042:0> drop_all 'employee'

Output
drop all hbase


9. Is_enabled

Is_enabled command is used to check if a table enables or not. If the table is disabled then this command will return “false” and if the table is not disabled then this command will return “true”.

Syntax
hbase(main):044:0> is_enabled ‘table_name’

Command
hbase(main):044:0> is_enabled 'employee'

Output
is enabled hbase


10. Alter

Alter command is used to make changes to an existing table. By using this command, we can change the maximum number of cells of a column family, set and delete table scope operators, and delete a column family from a table.

Syntax
hbase(main):001:0>  alter <tablename>, NAME=><column familyname>, VERSIONS=>5

Using alter command we will add a new column family 'emp_contact' in the employee table.

Let us see with the below example.

Command
hbase(main):001:0> alter 'employee', NAME='emp_contact', VERSIONS=>5

Output
alter table

Using alter command we will add multiple column families such as 'emp_id' and 'dept_id' in the employee table.

Let us see with the below example.

Command
hbase(main):001:0> alter 'employee','emp_address','emp_contact','emp_records', {NAME => 'emp_id', IN_MEMORY => true},{NAME => 'dept_id', VERSIONS => 6}

Output
alter multiple column

Using alter command we can delete the column family.

Let us see with below example in which we are deleting the “dept_id” column family from the “employee” table.

Command
hbase(main):003:0> alter 'employee', 'delete' => 'dept_id'

Output
delete hbase