HBase Shell 操作
基本操作
- 進入 HBase 用戶端指令行
bin/hbase shell
- 檢視幫助指令
help
- 檢視目前資料庫中有哪些表
list
表的操作
- 建立表
create 'student','info'
- 插入資料到表
put 'student','1001','info:sex','male'
put 'student','1001','info:age','18'
put 'student','1002','info:name','Janna'
put 'student','1002','info:sex','female'
put 'student','1002','info:age','20'
- 掃描檢視表資料
scan 'student'
scan 'student',{STARTROW => '1001', STOPROW => '1001'}
scan 'student',{STARTROW => '1001'}
- 檢視表結構
describe 'student'
- 更新指定字段的資料
put 'student','1001','info:name','Nick'
put 'student','1001','info:age','100'
- 檢視“指定行”或“指定列族:列”的資料
get 'student','1001'
get 'student','1001','info:name'
- 統計表資料行數
count 'student'
- 删除資料
删除某 rowkey 的全部資料
deleteall 'student','1001'
删除某 rowkey 的某一列資料
delete 'student','1002','info:sex'
- 清空表資料
truncate 'student'
提示:清空表的操作順序為先 disable,然後再 truncate。
- 删除表
首先需要先讓該表為 disable 狀态
disable 'student'
然後才能 drop 這個表
drop 'student'
- 變更表資訊
alter 'student',{NAME=>'info',VERSIONS=>3}
get 'student','1001',{COLUMN=>'info:name',VERSIONS=>3}