啟動命令
./hbase shell
退出命令
exit
創(chuàng)建表
create '表名稱', '列族名稱1','列族名稱2','列族名稱N'
create 'users','user_id','address','info'
列出全部表
list
得到表的描述
describe 'users'
刪除表
disable 'users' drop 'users'
添加記錄
put ‘表名稱’, ‘行鍵', '列名稱:', '值'
put 'users','xiaoming','info:age','24'
put 'users','xiaoming','info:birthday','1987-06-17'
put 'users','xiaoming','info:company','alibaba'
put 'users','xiaoming','address:contry','china'
put 'users','xiaoming','address:province','zhejiang'
put 'users','xiaoming','address:city','hangzhou'
put 'users','zhangyifei','info:birthday','1987-4-17'
put 'users','zhangyifei','info:favorite','movie'
put 'users','zhangyifei','info:company','alibaba'
put 'users','zhangyifei','address:contry','china'
put 'users','zhangyifei','address:province','guangdong'
put 'users','zhangyifei','address:city','jieyang'
put 'users','zhangyifei','address:town','xianqiao'
獲取一條記錄
get '表名稱', '行鍵'取得一個id的所有數(shù)據(jù)
get 'users','xiaoming'
獲取一個id碉碉,一個列族的所有數(shù)據(jù)
get 'users','xiaoming','info'
獲取一個id迷雪,一個列族中一個列的所有數(shù)據(jù)
get 'users','xiaoming','info:age'
更新記錄(重新寫一遍覆蓋)
put 'users','xiaoming','info:age' ,'29'
get 'users','xiaoming','info:age'
put 'users','xiaoming','info:age' ,'30'
get 'users','xiaoming','info:age'
- 獲取單元格數(shù)據(jù)的版本數(shù)據(jù)
get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>1}
get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>2}
get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>3}
- 獲取單元格數(shù)據(jù)的某個版本數(shù)據(jù)
get 'users','xiaoming',{COLUMN=>'info:age',TIMESTAMP=>1364874937056}
全表掃描
scan 'users'
查看某個表某個列中所有數(shù)據(jù)
scan "表名稱" , {COLUMNS=>'列族名稱:列名稱'}刪除xiaoming值的'info:age'字段
delete '表名' ,'行鍵' , '列名稱'
delete 'users','xiaoming','info:age' get 'users','xiaoming'
刪除整行
deleteall 'users','xiaoming'
統(tǒng)計表的行數(shù)
count '表名稱'
count 'users'
清空表
truncate 'users'