Let's take a look at some of the basic operations commands of the HBase shell, and I've listed several common hbase shell commands, as follows:
| Name |
Command-expression |
| Create a table |
Create ' table name ', ' column name 1 ', ' Column Name 2 ', ' Column name n ' |
| Add a record |
Put ' table name ', ' Row name ', ' Column name: ', ' value ' |
| View Records |
Get ' table name ', ' Row name ' |
| View the total number of records in a table |
Count ' table name ' |
| Deleting records |
Delete ' table name ', ' Row name ', ' column name ' |
| Delete a table |
To block the table before it can be deleted, the first step disable ' table name ' Second step drop ' table name ' |
| View all records |
Scan "Table name" |
| View all data in a column of a table |
Scan "table name", [' Column name: '] |
| Update record |
is to rewrite it again to overwrite |
First, the general operation
1. Querying Server Status
HBase (main): 024:0>status
3 servers, 0 dead,1.0000 average load
2. Querying the Hive version
HBase (main): 025:0>version
0.90.4, R1150278,sun Jul 15:53:29 PDT 2011
Second, DDL operations
1. Create a table
HBase (Main): 011:0>create ' member ', ' member_id ', ' address ', ' info '
0 row (s) in 1.2210seconds
2. Get a description of the table
HBase (main): 012:0>list
TABLE
Member
1 row (s) in 0.0160seconds
HBase (Main): 006:0>describe ' member '
DESCRIPTION ENABLED
{NAME = ' member ', families = [{name=> ' address ', Bloomfilter = ' NONE ', Replication_scope = ' 0 ', true
VERSIONS = ' 3 ', COMPRESSION = ' NONE ', TTL = ' 2147483647 ', BLOCKSIZE = ' 65536 ', in_memory = ' FA
LSE ', Blockcache = ' true '}, {NAME = ' info ', bloomfilter = ' NONE ', Replication_scope = ' 0 ', versi
ONS = ' 3 ', COMPRESSION = ' NONE ', ttl=> ' 2147483647 ', BLOCKSIZE = ' 65536 ', in_memory = ' false ',
Blockcache = ' true '}]}
1 row (s) in 0.0230seconds
3. Delete a column family, alter, disable, enable
We built 3 column families before, but found that the member_id is redundant because he is the primary key, so we're going to delete it.
HBase (Main): 003:0>alter ' member ',{name=> ' member_id ',method=> ' delete '}
Error:table Memberis enabled. Disable it first before altering.
Error, delete the column family must first give the table to disable off.
HBase (Main): 004:0>disable ' member '
0 row (s) in 2.0390seconds
HBase (Main): 005:0>alter ' member ',name=> ' member_id ',method=> ' delete '
0 row (s) in 0.0560seconds
HBase (Main): 006:0>describe ' member '
DESCRIPTION ENABLED
{NAME = ' member ', families = [{name=> ' address ', Bloomfilter = ' NONE ', Replication_scope = ' 0 ', false
VERSIONS = ' 3 ', COMPRESSION = ' NONE ', TTL = ' 2147483647 ', BLOCKSIZE = ' 65536 ', in_memory = ' FA
LSE ', Blockcache = ' true '}, {NAME = ' info ', bloomfilter = ' NONE ', Replication_scope = ' 0 ', versi
ONS = ' 3 ', COMPRESSION = ' NONE ', ttl=> ' 2147483647 ', BLOCKSIZE = ' 65536 ', in_memory = ' false ',
Blockcache = ' true '}]}
1 row (s) in 0.0230seconds
The column family has been deleted and we continue to use the table