In HBase, data are stored in tables with columns. Columns are regrouped in column families, which can be for example "personal" or "professional", each of these containing specific informations.
To create a table, you need to use the Admin Object, create it using :
Admin admin = connection.getAdmin();
Once you have this admin, you can start creating tables. First of all make sure this table doesn't exist already with the line
This method will return true if the table exists. When you have checked this, you can create your table using the lines
HTableDescriptor descriptor = new HTableDescriptor(TableName.valueOf("myTable")); descriptor.addFamily(new HColumnDescriptor("myFamily")); admin.createTable(descriptor);
You need to set at least of family for the table, and HBase reference book recommends not getting over 3 column families else you will lose performances.
Congratulations ! Your table has been created !
If you need to delete your table, you can use
Be sure to always disable the table first !
You now know how to manage tables in HBase.