Accessing HBase, and manipulating hbase, commands do not use semicolons
HBase Shell enters HBase
List View Table
HBase shell-d
HBase (main):024:0> scan '. META. '
============= Small Example ===================================================
1. Create a Table member
HBase (main):025:0> create ' member ', ' m_id ', ' address ', ' info '
2.list #查看所有表
3. View the table description
HBase (main):028:0> describe ' member '
4. Scan to view the data in the table
Scan ' member '
5.
Delete a column family m_id: Disable the table first (the data will be emptied if there are previous data in the table)
HBase (Main):030:0> disable ' member '
HBase (Main):033:0> is_enabled ' member '
HBase (main):034:0> alter ' member ',{name=> ' m_id ',method=> ' delete '}
Finally enable, otherwise you can't do anything else
HBase (main):038:0> enable ' member '
6. Insert several records
Put ' member ', ' Scutshuxue ', ' info:age ', ' 24 '
Put ' member ', ' Scutshuxue ', ' info:birthday ', ' 1987-06-17 '
Put ' member ', ' Scutshuxue ', ' info:company ', ' Alibaba '
Put ' member ', ' Scutshuxue ', ' address:contry ', ' China '
Put ' member ', ' Scutshuxue ', ' address:province ', ' Zhejiang '
Put ' member ', ' Scutshuxue ', ' address:city ', ' Hangzhou '
Scan ' member '
7. Get Data
Get all the data for an ID
HBase (Main): 001:0>get ' member ', ' Scutshuxue '
Get an ID, all data for a column family
HBase (Main): 002:0>get ' member ', ' Scutshuxue ', ' info '
Gets an ID that all data for a column in a column family
HBase (Main): 002:0>get ' member ', ' Scutshuxue ', ' info:age '
Get two versions of data with timestamp
HBase (Main): 010:0>get ' member ', ' Scutshuxue ',{column=> ' info:age ', timestamp=>1321586238965}
8. Update a record
Change the age of Scutshuxue to 99
HBase (Main): 004:0>put ' member ', ' Scutshuxue ', ' info:age ', ' 99 '
10.
How many rows are in the query table:
HBase (Main): 019:0>count ' member '
11.
Delete entire row
HBase (Main): 001:0>deleteall ' member ', ' Xiaofeng '
12.
Remove the ' info:age ' field with the value ID Xiaofeng
HBase (Main): 016:0>delete ' member ', ' temp ', ' info:age '
13.
Add the ' info:go ' field to the ' Xiaofeng ' ID and use the counter to implement the increment
HBase (Main):041:0> incr ' member ', ' Xiaofeng ', ' Info:go '
The value of COUNTER value is incremented by the continuous execution of incr above, Get_counter
Gets the value of the current count
HBase (Main): 069:0>get_counter ' member ', ' Xiaofeng ', ' info:age '
HBase (Main): 058:0>get ' member ', ' Xiaofeng ', ' Info:go '
Gets the value of the current count
HBase (Main): 069:0>get_counter ' member ', ' Xiaofeng ', ' info:age '
============================= Related Delete =========================
1.
Delete a column family: Disable the table first (the data will be emptied if there are previous data in the table)
HBase (Main):030:0> disable ' member '
HBase (Main):033:0> is_enabled ' member '
HBase (main):034:0> alter ' member ',{name=> ' m_id ',method=> ' delete '}
Finally enable, otherwise you can't do anything else
HBase (main):038:0> enable ' member '
2.
Delete entire row
HBase (Main): 001:0>deleteall ' scores ', ' Xiaofeng '
3.
Empty the entire table:
HBase (Main): 035:0>truncate ' scores '
HBase is the ability to implement truncate by dropping disable off and then dropping and rebuilding the table.
4.
Drop a table (first disable, drop)
HBase (Main): 029:0>disable ' scores '
HBase (Main): 029:0>drop ' scores '
===================== Basic Operation ===========================================
1.
Whether the query table exists
HBase (Main): 021:0>exists ' scores '
2.
Determine if the table is enable
HBase (Main): 034:0>is_enabled ' scores '
3.
Determine if the table is disable
HBase (Main): 032:0>is_disabled ' scores '
4.
List all the tables
HBase (main): 028:0>list
5.
Create a Table member
HBase (main):025:0> create ' member ', ' m_id ', ' address ', ' info '
6.
View table Description
HBase (main):028:0> describe ' member '
================= Query Operation ================================================
1.scan ' table name ' #查看所有数据
2.get is to view a column based on the primary key
Get ' table name ', ' primary key ' [, ' column Cluster name '] [, ' Column Cluster Name: Column name ']
=============================================================
Filter the contents of a query table
1.FirstKeyOnlyFilter () Gets the first column of the column family info for each row
HBase (main):002:0> scan ' student ',{columns=> ' info ',filter=> "(Firstkeyonlyfilter ())"}
2. See if the column cluster is Info,limit is the number of rows displayed, StartRow is the primary key for the start row
HBase (main):008:0> scan ' student ', {columns=>[' info '],limit=>4,startrow=> ' 200977100710 '}
3. View the column cluster is Info,name
HBase (main):007:0> scan ' student ', {columns=>[' info ', ' name '],limit=>4,startrow=> ' 200977100710 '}
HBase Shell Basic Command Summary