用hbase的時候,老是忘記一些shell命令,每次都需要上網查,好麻煩,乾脆就把常見的shell都總結一下吧。
進入命令列介面相關命令
1、進入shell命令列介面
./hbase shell
表結構相關命令
2、建立表結構,這裡建立test表,包含fcol1,fcol2
3、顯示hbase中的表create 'test', 'fcol1', 'fcol2'
#或create 'test',
list
4、修改表結構
5、刪除乙個列族#首先停用test表
disable 'test'
#新增兩個列族fcol3和fcol4
alter 'test',name => 'fcol3',name => 'fcol4'
#啟用表
enable 'test'
6、新增列族fcol4同時刪除列族fcol3alter 'test', name => 'fcol4', method => 'delete'
#或alter 'test', 'delete' => 'fcol4'
alter 'test', ,
7、修改表的某個列族的版本號
alter 'test', name => 'fcol1', versions => 10
8、刪除表
9、啟動表disable 'test'
drop
'test'
enable 'test'
寫資料相關命令
10、向test表中插入資料,row key為rk01,列族fcol1中新增col1列,值為val1
11、向test表中插入資料,row key為rk01,列族fcol1中新增col2列,值為val2put
'test', 'rk001', 'fcol1:col1', 'val1'
12、向test表中插入資料,row key為rk01,列族fcol1中新增col3列,值為val3put
'test', 'rk01', 'fcol1:col2', 'val2'
13、向test表中插入資料,row key為rk01,列族fcol1中新增col4列,值為val4put
'test', 'rk01', 'fcol1:col3','val3'
get讀資料相關命令put
'test', 'rk01', 'fcol1:col4', 'val4'
14、獲取test表中row key為rk01的所有資料
15、獲取test表中row key為rk01,fcol1列族的資訊get
'test', 'rk01'
16、獲取test表中row key為rk01,fcol1列族的col1和col2列的資訊get
'test', 'rk01', 'fcol1'
17、獲取test表中row key為rk01,fcol1和fcol2列族的所有資訊get
'test', 'rk01', 'fcol1:col1', 'fcol1:col2'
17、獲取test表中row key為rk01,列族為fcol1,版本號最新5個的資訊get
'test', 'rk01', 'fcol1', 'fcol2'
#或get
'test', 'rk01',
18、獲取test表中row key為rk01,cell的值為***的資訊get 'test', 'rk01',
get 'test', 'rk01',
get 'test', 'rk01',
scan讀資料相關命令get
'test', 'rk01',
get'test', 'rk01',
19、查詢test表中的所有資訊
scan 'test'
20、查詢test表中列族為fcol1的資訊
21、查詢test表中列族為fcol1和fcol2的資訊scan 'test',
scan 'test',
22、查詢test表中列族為fcol1和fcol2且列標示符中含有abc字元的資訊scan 'test',
scan 'test',
scan 'test',
23、查詢test表中列族為fcol1,rk範圍是[rk01, rk03)的資料
scan 'test',
24、查詢test表中row key以rk字元開頭的
scan 'test',
24、查詢test表中指定timerange 範圍的資料
scan 'test',
刪除表資料相關命令
25、刪除test表row key為rk01,列標示符為fcol1:col1的資料
26、刪除test表row key為rk01,列標示符為fcol1:col1,timestamp為1292343123415的資料delete
'test', 'rk01', 'fcol1:col1'
清空表資料相關命令delete
'test', 'rk01', 'fcol1:col1', 1292343123415
27、清空表資料
truncate
'test'
HBase 常見 shell 操作
檢視當前所有表 list 建立表 create table name column family 刪除列族 alter table name delete columnfamily 檢視表內容 list table name 檢視表描述 describe table name 插入資料 put ta...
HBase 常用Shell命令
1.檢視hbase中存在的所有表 list hbase main list2.建立新的表 create 使用create命令來建立乙個新的表。在建立的時候,必須指定表名和列族名 hbase中的表至少有乙個列族 create hbase main create test 3.檢視表結構 describ...
HBASE 常用shell命令
1 建立表和列族 create student info address 2 向表中插入資料 put student 1 info age 20 put student 1 info name wang put student 1 info class 1 put student 1 address...