(1)建立一个表格scores 具有两个列族grade 和courese
hbase(main):001:0> create 'scores','grade', 'course'
0 row(s) in 0.4780 seconds
(2)查看当前HBase中具有哪些表
hbase(main):002:0> list
TABLE
scores
1 row(s) in 0.0270 seconds
create 'frp','f'
(3)查看hbase帮助信息
hbase(main):008:0> help create
Examples:
hbase> create 't1', {NAME => 'f1', VERSIONS => 5}
hbase> create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}
hbase> # The above in shorthand would be the following:
hbase> create 't1', 'f1', 'f2', 'f3'
hbase> create 't1', {NAME => 'f1', VERSIONS => 1, TTL => 2592000, BLOCKCACHE => true}
hbase> create 't1', 'f1', {SPLITS => ['10', '20', '30', '40']}
hbase> create 't1', 'f1', {SPLITS_FILE => 'splits.txt'}
hbase> # Optionally pre-split the table into NUMREGIONS, using
hbase> # SPLITALGO ("HexStringSplit", "UniformSplit" or classname)
hbase> create 't1', 'f1', {NUMREGIONS => 15, SPLITALGO => 'HexStringSplit'}
(4)查看表的描叙
hbase(main):009:0> describe 'frp'
DESCRIPTION ENABLED
{NAME => 'frp', FAMILIES => [{NAME => 'f1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTE true
R => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VE
RSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE => '6553
6', IN_MEMORY => 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
1 row(s) in 0.9370 seconds
(5)查看表中有多少行记录
hbase(main):010:0> count 'frp'
Current count: 1000, row: 1898
Current count: 2000, row: 2798
Current count: 3000, row: 3698
Current count: 4000, row: 4598
Current count: 5000, row: 5498
Current count: 6000, row: 6398
Current count: 7000, row: 7298
Current count: 8000, row: 8198
Current count: 9000, row: 9098
Current count: 10000, row: 9999
10000 row(s) in 1.5640 seconds
(6)查询表frp每一行的列族f1的第一个列
hbase(main):002:0> scan 'frp',{COLUMNS=>'f1',FILTER=>"(FirstKeyOnlyFilter())"}
ROW COLUMN+CELL
1 column=f1:ACTIVE, timestamp=1392357839360, value=1
10 column=f1:ACTIVE, timestamp=1392357839360, value=1
100 column=f1:ACTIVE, timestamp=1392357839360, value=1
1000 column=f1:ACTIVE, timestamp=1392357839651, value=1
10000 column=f1:ACTIVE, timestamp=1392357842629, value=1
1001 column=f1:ACTIVE, timestamp=1392357839651, value=1
1002 column=f1:ACTIVE, timestamp=1392357839651, value=1
1003 column=f1:ACTIVE, timestamp=1392357839651, value=1
1004 column=f1:ACTIVE, timestamp=1392357839651, value=1
1005 column=f1:ACTIVE, timestamp=1392357839651, value=1
(7)查看列簇是info,LIMIT是显示的行数,STARTROW是开始行对应的是主键
hbase(main):001:0> scan 'frp',{COLUMNS=>['f1'],LIMIT=>4,STARTROW=>'10'}
ROW COLUMN+CELL
10 column=f1:ACTIVE, timestamp=1392357839360, value=1
10 column=f1:ALLOWEPOSCANCEL, timestamp=1392357839360, value=1
10 column=f1:ALLOWPARTREFUND, timestamp=1392357839360, value=1
10 column=f1:ALLOWREFUND, timestamp=1392357839360, value=1
10 column=f1:AVAILABLEFOR, timestamp=1392357839360, value=Availablefor
10 column=f1:BANKACTTYPE, timestamp=1392357839360, value=Bankacttype
10 column=f1:BANK_ID, timestamp=1392357839360, value=Bank_id
10 column=f1:BRANCHID, timestamp=1392357839360, value=Branchid
10 column=f1:CHANNEL, timestamp=1392357839360, value=Channel
10 column=f1:CURRENCY, timestamp=1392357839360, value=Currency
10 column=f1:DEFAULTALLOW, timestamp=1392357839360, value=1
10 column=f1:DESCRIPTION, timestamp=1392357839360, value=Description
10 column=f1:FRPPAGE, timestamp=1392357839360, value=Frppage
10 column=f1:FRPTYPE, timestamp=1392357839360, value=Frptype
10 column=f1:G3PAYINTERFACE, timestamp=1392357839360, value=G3payinterface
10 column=f1:IPDETEUSABLE, timestamp=1392357839360, value=1
10 column=f1:NAME, timestamp=1392357839360, value=Name
10 column=f1:NOWIP, timestamp=1392357839360, value=Nowip
10 column=f1:OPTIMISTIC, timestamp=1392357839360, value=1
10 column=f1:PERTRXLIMIT, timestamp=1392357839360, value=10
10 column=f1:PREFERRED, timestamp=1392357839360, value=1
10 column=f1:REFUNDCOUNTLIMIT, timestamp=1392357839360, value=1
10 column=f1:REFUNDDELAYDAYS, timestamp=1392357839360, value=1
10 column=f1:REFUNDHANDLETYPE, timestamp=1392357839360, value=Refundhandletype
10 column=f1:TRXTYPEFILTER, timestamp=1392357839360, value=Trxtypefilter
100 column=f1:ACTIVE, timestamp=1392357839360, value=1
100 column=f1:ALLOWEPOSCANCEL, timestamp=1392357839360, value=1
100 column=f1:ALLOWPARTREFUND, timestamp=1392357839360, value=1
100 column=f1:ALLOWREFUND, timestamp=1392357839360, value=1
100 column=f1:AVAILABLEFOR, timestamp=1392357839360, value=Availablefor
100 column=f1:BANKACTTYPE, timestamp=1392357839360, value=Bankacttype
100 column=f1:BANK_ID, timestamp=1392357839360, value=Bank_id
100 column=f1:BRANCHID, timestamp=1392357839360, value=Branchid
100 column=f1:CHANNEL, timestamp=1392357839360, value=Channel
100 column=f1:CURRENCY, timestamp=1392357839360, value=Currency
100 column=f1:DEFAULTALLOW, timestamp=1392357839360, value=1
100 column=f1:DESCRIPTION, timestamp=1392357839360, value=Description
100 column=f1:FRPPAGE, timestamp=1392357839360, value=Frppage
100 column=f1:FRPTYPE, timestamp=1392357839360, value=Frptype
100 column=f1:G3PAYINTERFACE, timestamp=1392357839360, value=G3payinterface
100 column=f1:IPDETEUSABLE, timestamp=1392357839360, value=1
100 column=f1:NAME, timestamp=1392357839360, value=Name
100 column=f1:NOWIP, timestamp=1392357839360, value=Nowip
100 column=f1:OPTIMISTIC, timestamp=1392357839360, value=1
100 column=f1:PERTRXLIMIT, timestamp=1392357839360, value=10
100 column=f1:PREFERRED, timestamp=1392357839360, value=1
100 column=f1:REFUNDCOUNTLIMIT, timestamp=1392357839360, value=1
100 column=f1:REFUNDDELAYDAYS, timestamp=1392357839360, value=1
100 column=f1:REFUNDHANDLETYPE, timestamp=1392357839360, value=Refundhandletype
100 column=f1:TRXTYPEFILTER, timestamp=1392357839360, value=Trxtypefilter
1000 column=f1:ACTIVE, timestamp=1392357839651, value=1
1000 column=f1:ALLOWEPOSCANCEL, timestamp=1392357839651, value=1
1000 column=f1:ALLOWPARTREFUND, timestamp=1392357839651, value=1
1000 column=f1:ALLOWREFUND, timestamp=1392357839651, value=1
1000 column=f1:AVAILABLEFOR, timestamp=1392357839651, value=Availablefor
1000 column=f1:BANKACTTYPE, timestamp=1392357839651, value=Bankacttype
1000 column=f1:BANK_ID, timestamp=1392357839651, value=Bank_id
1000 column=f1:BRANCHID, timestamp=1392357839651, value=Branchid
1000 column=f1:CHANNEL, timestamp=1392357839651, value=Channel
1000 column=f1:CURRENCY, timestamp=1392357839651, value=Currency
1000 column=f1:DEFAULTALLOW, timestamp=1392357839651, value=1
1000 column=f1:DESCRIPTION, timestamp=1392357839651, value=Description
1000 column=f1:FRPPAGE, timestamp=1392357839651, value=Frppage
1000 column=f1:FRPTYPE, timestamp=1392357839651, value=Frptype
1000 column=f1:G3PAYINTERFACE, timestamp=1392357839651, value=G3payinterface
1000 column=f1:IPDETEUSABLE, timestamp=1392357839651, value=1
1000 column=f1:NAME, timestamp=1392357839651, value=Name
1000 column=f1:NOWIP, timestamp=1392357839651, value=Nowip
1000 column=f1:OPTIMISTIC, timestamp=1392357839651, value=1
1000 column=f1:PERTRXLIMIT, timestamp=1392357839651, value=10
1000 column=f1:PREFERRED, timestamp=1392357839651, value=1
1000 column=f1:REFUNDCOUNTLIMIT, timestamp=1392357839651, value=1
1000 column=f1:REFUNDDELAYDAYS, timestamp=1392357839651, value=1
1000 column=f1:REFUNDHANDLETYPE, timestamp=1392357839651, value=Refundhandletype
1000 column=f1:TRXTYPEFILTER, timestamp=1392357839651, value=Trxtypefilter
10000 column=f1:ACTIVE, timestamp=1392357842629, value=1
10000 column=f1:ALLOWEPOSCANCEL, timestamp=1392357842629, value=1
10000 column=f1:ALLOWPARTREFUND, timestamp=1392357842629, value=1
10000 column=f1:ALLOWREFUND, timestamp=1392357842629, value=1
10000 column=f1:AVAILABLEFOR, timestamp=1392357842629, value=Availablefor
10000 column=f1:BANKACTTYPE, timestamp=1392357842629, value=Bankacttype
10000 column=f1:BANK_ID, timestamp=1392357842629, value=Bank_id
10000 column=f1:BRANCHID, timestamp=1392357842629, value=Branchid
10000 column=f1:CHANNEL, timestamp=1392357842629, value=Channel
10000 column=f1:CURRENCY, timestamp=1392357842629, value=Currency
10000 column=f1:DEFAULTALLOW, timestamp=1392357842629, value=1
10000 column=f1:DESCRIPTION, timestamp=1392357842629, value=Description
10000 column=f1:FRPPAGE, timestamp=1392357842629, value=Frppage
10000 column=f1:FRPTYPE, timestamp=1392357842629, value=Frptype
10000 column=f1:G3PAYINTERFACE, timestamp=1392357842629, value=G3payinterface
10000 column=f1:IPDETEUSABLE, timestamp=1392357842629, value=1
10000 column=f1:NAME, timestamp=1392357842629, value=Name
10000 column=f1:NOWIP, timestamp=1392357842629, value=Nowip
10000 column=f1:OPTIMISTIC, timestamp=1392357842629, value=1
10000 column=f1:PERTRXLIMIT, timestamp=1392357842629, value=10
10000 column=f1:PREFERRED, timestamp=1392357842629, value=1
10000 column=f1:REFUNDCOUNTLIMIT, timestamp=1392357842629, value=1
10000 column=f1:REFUNDDELAYDAYS, timestamp=1392357842629, value=1
10000 column=f1:REFUNDHANDLETYPE, timestamp=1392357842629, value=Refundhandletype
10000 column=f1:TRXTYPEFILTER, timestamp=1392357842629, value=Trxtypefilter
4 row(s) in 0.3480 seconds
(8)hbase shell按命令行查询
hbase(main):012:0> get 'org','31'
COLUMN CELL
f:DEP_NAME timestamp=1393816430327, value=develop
f:EMPEE_NO timestamp=1393816430326, value=20
f:MANAGER timestamp=1393816430327, value=aaa
f:MAX_TOTAL timestamp=1393816430327, value=100
4 row(s) in 0.0110 seconds
hbase(main):013:0> get 'org','ZCBM'
COLUMN CELL
f:c timestamp=1393414483443, value=8a80402d2f3fb887012f3fb9b7372078|\x1BZCBM|\x1B\xE4\xBB\x81\xE5\xAF\x
BF\xE5\x8E\xBF\xE5\x86\x9C\xE6\x9D\x91\xE4\xBF\xA1\xE7\x94\xA8\xE5\x90\x88\xE4\xBD\x9C\xE8\x81\x94\
xE7\xA4\xBE\xE5\xAF\x8C\xE5\x8A\xA0\xE5\xAF\x8C\xE4\xB8\xAD\xE8\xB7\xAF\xE5\x88\x86\xE7\xA4\xBE|\x1
B3|\x1B5793|\x1B\xE4\xBB\x81\xE5\xAF\xBF\xE5\x8E\xBF\xE5\x86\x9C\xE6\x9D\x91\xE4\xBF\xA1\xE7\x94\xA
8\xE5\x90\x88\xE4\xBD\x9C\xE8\x81\x94\xE7\xA4\xBE|\x1B1|\x1B2013-09-13|\x1B2013-09-13|\x1B2013-09-1
3-13
1 row(s) in 0.0370 seconds
(9)删除hbase表数据
hbase(main):010:0> deleteall 'org','31'
0 row(s) in 0.0100 seconds