Ways to create a table in HBase

Viewing 1 reply thread
  • Author
    Posts
    • #6574
      DataFlair TeamDataFlair Team
      Spectator

      In HBase, tables can be created by two ways :

      # Using HBase shell

      # Using Java API

    • #6575
      DataFlair TeamDataFlair Team
      Spectator

      In HBase, it is possible to create a Table in two ways:

      i. HBase Create Table
      ii. Creating a Table Using Java API

      So, let’s learn both in brief:

      i. HBase Create Table
      With the help of Create command, we can create a table in HBase. But as a condition, we need to specify the table name and the Column Family name to create one.

      Syntax

      create ‘<table name>’,’<column family>’

      ii. Creating a Table Using Java API
      Else we can use createTable() method of HBaseAdmin class for creating a table. To do so, steps are:

      Step1: Instantiate HBaseAdmin

      Do instantiate the Configuration class. Then also pass this instance to HBaseAdmin, since the class needs the Configuration object as a parameter:

      Configuration conf = HBaseConfiguration.create();

      HBaseAdmin admin = new HBaseAdmin(conf);

      Step2: Create TableDescriptor

      Step 3: Execute through Admin

      with the help of createTable() method of HBaseAdmin class, it is possible to execute the created table in Admin mode.

      admin.createTable(table);

      However, to learn all Table Management Commands in HBase, follow the link: Table Management Commands in HBase

Viewing 1 reply thread
  • You must be logged in to reply to this topic.