What is the command to create a table in HBase?
To create a table in HBase, you can use either the HBase Shell or the HBase Java API. Below are the commands to create a table using the HBase Shell:
Run the HBase Shell. Enter the following commands in the terminal.
hbase shell
In the HBase Shell, use the `create` command to create a table. For example, the following command will create a table named `my_table` and specify one or more column families within it.
create 'my_table', 'column_family1', 'column_family2'
`my_table` refers to the name of the table, while `column_family1` and `column_family2` are the names of the column families.
Optional parameters can be used to define the attributes of the table, as shown below:
create 'my_table', {NAME => 'column_family1', VERSIONS => 1}, {NAME => 'column_family2',VERSIONS => 2}
In the example above, we specified a maximum of one version for ‘column_family1’ and a maximum of two versions for ‘column_family2’.
After creating the table, you can use the ‘list’ command to view all the tables that have been created.
list
This will display all existing tables.
These are the basic steps and commands for creating a table in HBase Shell. Remember that you can also use the HBase Java API to programmatically create tables.