HBase基本操作

2021-10-25 01:36:56 字數 3120 閱讀 7651

列出所有命名空間

list_namespace

建立命名空間

create_namespace 『name』

列出hbase中命名空間中的所有表

list_namespace_tables 『name』

統計表中行的數量

count 『命名空間:表名』

每次讀取1000行

count 『命名空間:表名』 ,

退出exit

顯示表的相關的詳細資訊

describe 『表名』

使表有效

enable 『表名』

使表無效

disable 『表名』

建立表create 『命名空間:表名』,『列簇』,『列簇』

清空表truncate 『命名空間:表名』

##run below in hbase shell

##基本命令

version

status

whoami

help

##操作命令

##建立表

create 『customer』, ,

##列出所有表

list

##檢視表資訊

desc 『customer』

##判斷表是否存在

exists 『customer』

##表中插入資料語法:put 』

』,』row_key1』,』

colfamily:colname』,』』

put 『customer』, 『jsmith』, 『addr:city』, 『montreal』

put 『customer』, 『jsmith』, 『addr:state』, 『on』

put 『customer』, 『jsmith』, 『order:numb』, 『123456』

put 『customer』, 『jsmith』, 『order:date』, 『2015-12-19』

##根據rowkey獲取資料

get 『customer』, 『jsmith』

##獲取指定cf資料的兩種方式

get 『customer』, 『jsmith』,『addr』

get 『customer』, 『jsmith』,

##獲取指定列的資料

get 『customer』, 『jsmith』,

##更新資料

put 『customer』, 『jsmith』, 『order:numb』, 『654321』

get 『customer』, 『jsmith』,

##修改多版本儲存

alter 『customer』,name=>『order』, versions=>5

##插入多行資料

put 『customer』, 『jsmith』, 『order:numb』, 『1235』

put 『customer』, 『jsmith』, 『order:numb』, 『1236』

put 『customer』, 『jsmith』, 『order:numb』, 『1237』

put 『customer』, 『jsmith』, 『order:numb』, 『1238』

put 『customer』, 『njones』, 『addr:city』, 『miami』

put 『customer』, 『njones』, 『addr:state』, 『fl』

put 『customer』, 『njones』, 『order:numb』, 『5555』

put 『customer』, 『tsimmons』, 『addr:city』, 『dallas』

put 『customer』, 『tsimmons』, 『addr:state』, 『tx』

put 『customer』, 『jsmith』, 『addr:city』, 『denver』

put 『customer』, 『jsmith』, 『addr:state』, 『co』

put 『customer』, 『jsmith』, 『order:numb』, 『6666』

put 『customer』, 『njones』, 『addr:state』, 『tx』

put 『customer』, 『amiller』, 『addr:state』, 『tx』

##多版本資料查詢

get 『customer』, 『jsmith』,

##全掃瞄

scan 『customer』,

##指定rowkey範圍查詢

scan 『customer』,

##統計表中資料個數

count 『customer』

##刪除語法

##delete 『』, 『』, 『』,

##deleteall 『』, 『』

##刪除整行

deleteall 『customer』,『njones』

##刪除乙個單元格的值

delete 『personal』,『2』,『personal_data:age』,1505286495492

##刪除一列

delete 『customer』,『njones』,『addr:city』

##刪除乙個列族資料,下面的操作是不正確的

##delete 『customer』, 『jsmith』, 『addr』

##下面操作是正確的

alter 『customer』,『delete』=>『addr』

##啟動表,禁用表

disable 『customer』

is_disabled 『customer』

enable 『customer』

##清空表

truncate 『customer』

##刪除表,注意刪除之前,如果表的狀態不是disabled,需要先禁用表,才能刪除,否則報錯

drop 『customer』

hbase org.apache.hadoop.hbase.mapreduce.importtsv

-dimporttsv.separator=,

-dimporttsv.columns=「hbase_row_key,baseinfo:name,privateinfo:courseid」

student file:///opt/software/hbase/stu.csv

HBase 基本操作

如何新增列族很簡單,跟rdbms一樣 直接用alter,但是alter之前必須先disable這個表 disable test 先禁用,目前我用的hbase 0.92版本,尚需要先disable,後期版本不知是否可以不用disable alter test 直接alter 後邊寫入你要 加的列族 e...

Hbase基本操作

hbase shell是乙個基於ruby的語言開發的命令列操作環境。在hmaser主機上,可以通過命令列鍵入hbase shell,進入hbase的命令列環境,進入hbase shell後會看到類似如下形式的命令提示符 hbase main 002 0 在shell模式下,可以對集群 資料表和資料進...

Hbase基本操作

建立乙個名為pageviews的表,並具有名為info的列簇 每張表至少要有乙個列簇,因此我們建立了info,現在,看看我們的表,執行下面list命令 describe命令返回表的詳細資訊,包括列簇的列表,這裡我們建立的僅有乙個 info,現在為表新增以下資料,下面命令是在info中新增新的行 pu...