1. Enter the HBase command line
. /HBase Shell
2. Basic commands
Display a list of tables in HBase
List
Querying all the information in the user table Scan
' Users '
Clears the data Truncate in the user table ( equivalent to disable + drop + Create)
' Users '
Delete Table drop
' User ' Drop ' User '
3. Modify the table structure
First disable the user table ( new version not used) Disable ' user ', and finally enable the table enabled ' user '
Add a new column family F1
Alter ' User ' = ' F1 '
Delete a column family F1 ( do not specify method, default is Add column family )
alter " , NAME => '
Add Column Family F1 also delete column family F2
Alter ' User ' = ' F1 ' = ' F2 ' = ' Delete '}
Change the F1 column family version number of the user table to 5
Alter ' people ' = ' Info ' = 5
4. Create a table
Create a user table with info, data two column families
Create 'User','Info','Data'Create 'User', {NAME= 'Info', VERSIONS= '3'},{name = 'Data', VERSIONS = '3‘}
5. Delete data
Delete the user table row key is rk0001, and the column designator is info:name data
Delete ' User ' ' rk0001 ' ' Info:name '
Delete the user table row key is rk0001 and the column identifier is info:name,timestamp 1392383705316 data
Delete ' User ' ' rk0001 ' ' Info:name ' 1392383705316
6. Add Data
Insert information into the user table, row key is rk0001, column family info adds the Name column identifier, and the value is Zhangsan
' User ' ' rk0001 ' ' Info:name ' ' Zhangsan '
7. Finding data
Get all the information for row key rk0001 in the user table
' User ' ' rk0001 '
Gets all the information for row key in the user table for the Rk0001,info column family
' User ' ' rk0001 ' ' Info '
Gets information about the name, age column identifier of row key in the user table for the Rk0001,info column family
' User ' ' rk0001 ' ' Info:name ' ' Info:age '
Get information for row key in the user table for Rk0001,info and data two column families
Get'User','rk0001','Info','Data'Get'User','rk0001', {COLUMN = [' info ', ' data ']}get'User','rk0001', {COLUMN = [' info:name ', ' Data:pic ']}
Gets the information of the user table in row key rk0001, the column family is info, the version number is the latest 5
Get' User','rk0001', {COLUMN = 'Info', VERSIONS= 5}get'User','rk0001', {COLUMN = 'Info:name', VERSIONS= 5}
Find data cell with timestamp range,Timerange=>[t1,t2] is a time period that contains T1 but does not contain T2
There are only two parameters behind scan, only with RowKey + restrictions
Get'User','rk0001', {COLUMN = 'Info:name', VERSIONS= 5, Timerange= [1392368783980, 1392380169184]}
Scan'User', {Timerange= [1392368783980, 1392380169184]}
Query data for the column family in the user table as Info,rowkey range is [rk0001, rk0003) " cannot use get"
' people ' = ' Info ' = ' rk0001 ' = ' rk0003 '}
Set the cell to save only 3 versions of version, and the old superfluous will be overwritten.
However, with the following command, 5 versions are queried because the old version is flagged for deletion, but it is not flush in memory
When HBase restarts, the marked record will not be found in the
RAW = True indicates that only the column family columns = ' info ' is valid, and for columns = ' info:age ' ERROR
' Users ' = ' Info ' RAW = = 5}
Query the "filter keyword" in the user table that starts with the RK character Rowkey
' User ', {FILTER= =' Prefixfilter ('rk')}
Get binary binary with a value of "China" cell
This is because Chinese characters are stored in hbase and are stored "valuefilter" in binary form
Put'User','rk0002','info:nationality','China'Get'User','rk0002', {FILTER="Valuefilter (=,'binary: China')"}
Gets the Rowkey in the user table as RK0001, the column identifier filter (Qualifierfilter), which contains the information of a in the column name
' people ' ' rk0001 ' = (Qualifierfilter (=,'substring:a')) "}
Query for information in the user table that has the column family as info and data and that contains the a character in the column identifiers
' people ' = [' info ', ' data '] = (Qualifierfilter (=,'substring:a')) "}
HBase Shell Related