HBase控制檯Shell的命令

HBase簡單使用

hbase控制檯終端操作

啓動hbase的shell
$ bin/hbase shell
查看幫助命令
hbase(main)> help
查看當前數據庫中有哪些表
hbase(main)> list

表的操作

注意:在hbase shell中退格需要用ctrl+退格鍵

創建表
 -- create '表名,'列族(colum-family)'
ex: hbase> create 'student','info'
插入數據
hbase> put '表名''rowkey','列族名:列名1','值'
ex: hbase> put 'student','1001','info:name','daxiong'
hbase(main) > put 'student','1001','info:name','Thomas'
hbase(main) > put 'student','1001','info:sex','male'
hbase(main) > put 'student','1001','info:age','18'
hbase(main) > put 'student','1002','info:name','Janna'
hbase(main) > put 'student','1002','info:sex','female'
hbase(main) > put 'student','1002','info:age','20'
查看數據
--查看全表
hbase > scan 'student'
-- 查看指定範圍
hbase > scan 'student',{STARTROW => '1001',STOPROW => '1002'}
-- 查看指定行
hbase > get 'student','1001'
hbase > get 'student','1001','info'
hbase > get 'student','1001','info:name'

上述操作的區間:前閉後開

查看錶結構
hbase(main): describe 'student'
刪除數據
--刪除某rowkey的全部數據
hbase(main) > deleteall 'student','1001'
--刪除某rowkey的全部數據
hbase(main) > deleteall 'student','1001','info:sex'
清空表
hbase(main) > truncate 'student'

清空表的操作順序爲先disable,然後再truncating

刪除表
--首先需要先讓該表爲disable狀態
hbase(main) > disable 'student'
--然後才能drop這個表
hbase(main) > drop 'student'

如果直接drop表,會報錯:Drop the named table. Tablemust first be disabled

ERROR: Table student is enabled. Disable itfirst.

統計表數據行數
hbase(main) > count 'student'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章