Hbase Commands: Create ',' '
Hbase Commands: Create ',' '
● Hbase shell
HBase contains a shell using which you can communicate with HBase. HBase uses the
Hadoop File System to store its data. It will have a master server and region servers.
The data storage will be in the form of regions (tables). These regions will be split up
and stored in region servers.
The master server manages these region servers and all these tasks take place on
HDFS
● Create Table
You can create a table using the create command, here you must specify the table name
and the Column Family name. The syntax to create a table in HBase shell is shown
below.
list is the command that is used to list all the tables in HBase. Given below is the syntax
of the list command.
hbase(main):001:0 > list
hbase(main):002:0> list
TABLE
Emp
1 row(s) in 0.0330 seconds
=> ["emp"]
● Disabling a Table
To delete a table or change its settings, you need to first disable the table using the
disable command. After disabling the table, you can still sense its existence through list
and exists commands.Given below is the syntax to disable a table:
true
0 row(s) in 0.0110 seconds
● Enabling a Table
This command returns the description of the table. Its syntax is as follows:
● Alter Command
Alter is the command used to make changes to an existing table. Using this command,
you 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.
You can verify the existence of a table using the exists command. The following
example shows how to use this command.
● Drop Table
Using the drop command, you can delete a table. But before dropping a table, you have
to disable it.
Using the put command, you can insert rows into a table. Its syntax is as follows:
The scan command is used to view the data in HTable. Using the scan command, you
can get the table data. Its syntax is as follows:
You can update an existing cell value using the put command.The newly given value
replaces the existing value, updating the row. To do so, just follow the same syntax and
mention your new value as shown below.
The get command and the get() method of HTable class are used to read data from a
table in HBase. Using the get command, you can get a single row of data at a time. Its
syntax is as follows:
● Count Command
You can count the number of rows of a table using the count command. Its syntax is as
follows:
This command disables drops and recreates a table. The syntax of truncate is as follows: