1. 程式人生 > >Hbase Shell 數據操作說明

Hbase Shell 數據操作說明

說明 tab time get ace ssi pro stop col


啟動、關閉hbase
./bin/start-hbase.sh
./bin/stop-hbase.sh


查詢HBase版本。它的語法如下:
hbase(main):010:0> version


建表
create ‘<table name>’,’<column family>’
create ‘emp‘, ‘personal data‘, ’professional data’


列出所有表:list


表空間:
create_namespace ‘name‘


使用put命令,可以插入行到一個表。它的語法如下:
put ’<namespace:table name>’,’row1’,’<colfamily:colname>’,’<value>’
(表空間名非必填)

put ‘emp‘,‘1‘,‘personal data:name‘,‘raju‘
put ‘emp‘,‘1‘,‘personal data:city‘,‘hyderabad‘
put ‘emp‘,‘1‘,‘professional data:designation‘,‘manager‘
put ‘emp‘,‘1‘,‘professional data:salary‘,‘50000‘

put ‘emp‘,‘2‘,‘personal data:name‘,‘mike‘
put ‘emp‘,‘2‘,‘personal data:city‘,‘NanJing‘
put ‘emp‘,‘2‘,‘professional data:designation‘,‘CEO‘
put ‘emp‘,‘2‘,‘professional data:salary‘,‘99000‘


查詢表中所有數據:
hbase(main):026:0> scan ‘emp‘
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1510047547743, value=hyderabad
1 column=personal data:name, timestamp=1510047519200, value=raju
1 column=professional data:designation, timestamp=1510047567498, value=manager
1 column=professional data:salary, timestamp=1510047577830, value=50000
2 column=personal data:city, timestamp=1510047806635, value=NanJing
2 column=personal data:name, timestamp=1510047795408, value=mike
2 column=professional data:designation, timestamp=1510047812168, value=CEO
2 column=professional data:salary, timestamp=1510047818080, value=99000
2 row(s) in 0.0240 seconds


使用get命令獲取一行數據。它的語法如下:
get ’<table name>’,’row1’
get ‘emp‘ , ‘1‘


使用get方法讀取指定列:
hbase>get ‘table name‘, ‘rowid’, {COLUMN => ‘column family:column name ’}
get ‘emp‘, ‘2‘, {COLUMN=>‘personal data:name‘}

Hbase Shell 數據操作說明