创建表
create ‘TableName’, ‘ColumnFamily’
e.g: create ‘testTable’, ‘message’
查询表结构:
desc ‘TableName’
eg: desc ‘testTable’
查看当先HBase中具有哪些表
list
插入数据
格式:put ‘TableName’, ‘RowKey’, ‘columnFamily’
eg:
put ‘testTable’, ‘1’, ‘message:info’ , ‘hello Hbase’
put ‘testTable’, ‘1’, ‘message:msg’ , ‘Hello Hadoop’
put ‘testTable’, ‘2’, ‘message:info’, ‘a’
put ‘testTable’, ‘2’, ‘message:msg’, ‘b’
put ‘testTable’, ‘2’, ‘message:info’, ‘c’
put ‘testTable’, ‘2’, ‘message:info1’, ‘info’
删除表:
首先禁止表, 再删除
disable ‘tableName’
drop ‘tableName’
查询表中数据
scan ‘TableName’
通过rowKey 获取指定行
get ‘tableName’, ‘rowKey’
scan 'chb_20181016', { LIMIT => 10}
scan 'chb_20181016', { LIMIT => 30, STARTROW=>'1010A2.B1.B2-20100001_2108_117.131.19.173_' , STOPROW=>'1010A2.B1.B2-20100001_2108_117.131.19.173_a'}
filter, substring子串匹配
scan 'chb_20181016', { LIMIT => 30, STARTROW=>'1010A2.B1.B2-20100001_2108_117.131.19.173_' , STOPROW=>'1010A2.B1.B2-20100001_2108_117.131.19.173_a',
FILTER => " (SingleColumnValueFilter ('cf1', 'data', =, 'substring:,b183.240.203.66')) and (SingleColumnValueFilter ('cf1', 'data', =, 'substring:,e1'))"}