Hbase shell common operations

Common operations of Hbase Shell:
1. Create table
create 'table name', 'column family name 1', 'column family name 2' 




create 'testorder', 'info', 'orders'


2. View table 
View all table list: list
View information about a table: desc 'table name' or describe 'table name'
to see if the table exists: exists 'table name'


3. Insert data
put 'table name', 'rowkey value', 'column family: column name' ,'value' 




put 'testorder','00001','info:name','xiao1' 
put 'testorder','00001','info:age','22' 
put 'testorder','00001',' info:sex','male' 
put 'testorder','00001','orders:orderid','02018010022' 
 
put 'testorder','00001','  orders:price','21' 




put 'testorder','00002','info:name','xiao2' 
put 'testorder','00002','info:age','34' 
put 'testorder','00002','info:sex','女' 
put 'testorder','00002','orders:orderid','02018010055' 
put 'testorder','00002','orders:price','45' 






put 'testorder','00003','info:name' ,'xiao3' 
put 'testorder','00003','info:age','25' 
put 'testorder','00003','info:sex','male' 
put 'testorder','00003',' orders:orderid','02018010088' 
put 'testorder','00003','orders:price','27' 


4. Get table data


Get a single record: get 'table name', 'rowkey value' or get 'table name ','rowkey value','column family name'
scan the whole table: scan 'table name' or scan 'table name' , {COLUMNS=>'column family name' } Or scan 'table
name' , {COLUMNS=>'column family name:column name'}
scan 'testorder',{COLUMNS=>'info:age'} 


5. Delete table data
Delete column: delete 'table name' , 'row name' , 'column family: column'
delete the entire row: deleteall 'table name', 'rowkey'
clear the table data: truncate 'table name'


6. Delete the table
The table needs to be disabled before dropping it.
disable 'table name'
drop 'table name'


7. Filter
Check the value of the column is 22:
scan 'testorder',FILTER=>"ValueFilter(=,'binary:22')" 


Check the value of the column contains xiao:
scan 'testorder' ',FILTER=>"ValueFilter(=,'substring:xiao')" The  
column name starts with age, and the record with age is 22 or 25:
scan 'testorder', FILTER=>"ColumnPrefixFilter('ag') AND (ValueFilter (=,'binary:22') OR
ValueFilter(=,'binary:25') )" 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325761311&siteId=291194637