列出所有命名空间 list_namespace
创建命名空间 create_namespace ‘name’
列出hbase中命名空间中的所有表 list_namespace_tables ‘name’
统计表中行的数量 count ‘命名空间:表名’ 每次读取1000行 count ‘命名空间:表名’ ,{ INTERVAL => 1000 }
退出 exit
显示表的相关的详细信息 describe ‘表名’
使表有效 enable ‘表名’
使表无效 disable ‘表名’
创建表 create ‘命名空间:表名’,‘列簇’,‘列簇’
清空表 truncate ‘命名空间:表名’
##Run below in hbase shell ##基本命令 version status whoami help
##操作命令 ##创建表 create ‘customer’, {NAME=>‘addr’}, {NAME=>‘order’} ##列出所有表 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’,{COLUMNS=>[‘addr’]}
##获取指定列的数据 get ‘customer’, ‘jsmith’,{COLUMNS=>[‘order:numb’]}
##更新数据 put ‘customer’, ‘jsmith’, ‘order:numb’, ‘654321’ get ‘customer’, ‘jsmith’,{COLUMNS=>[‘order:numb’]}
##修改多版本存储 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’, {COLUMNS=>[‘order:numb’], VERSIONS => 5}
##全扫描 scan ‘customer’, {COLUMNS=>[‘order:numb’], VERSIONS => 2}
##指定rowkey范围查询 scan ‘customer’, {STARTROW => ‘j’, STOPROW => ‘t’}
##统计表中数据个数 count ‘customer’
##删除语法 ##delete ‘<table_name>’, ‘<row_key>’, ‘<column_name >’, <time_stamp_value> ##deleteall ‘<table_name>’, ‘<row_key>’
##删除整行 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