Thursday, May 30, 2013

create hbase table then put value into it with hbase shell



connect with hbase shell 
    mapr@cvlqepn3:/opt/mapr/hbase/hbase-0.94.5/conf> hbase shell
    HBase Shell; enter 'help<RETURN>' for list of supported commands.
    Type "exit<RETURN>" to leave the HBase Shell
    Version 0.94.5-mapr, r1dddcf01de3d37559586994b6727827c9493e0f0, Wed May 1 17:42:07 PDT 2013

    Not all HBase shell commands are applicable to MapR tables.
    Consult MapR documentation for the list of supported commands.

create table t1 and family t1 and family t2
families are static 99% of the time. They are like column in RDBMS
    hbase(main):001:0> create 't1','f1','f2'
    0 row(s) in 1.9250 seconds

put colume col1 value v1 into family 'f1' in row 'r1' , put column col2,col3 value 'v2' into family 'f2' in row 'r2'
hbase(main):002:0> put 't1','r1','f1:col1','v1'
0 row(s) in 0.2050 seconds

hbase(main):003:0> put 't1','r2','f2:col2','v2'
0 row(s) in 0.0130 seconds

hbase(main):004:0> put 't1','r2','f2:col3','v2'
0 row(s) in 0.0040 seconds

Show data in table t1
hbase(main):005:0> scan 't1'
ROW COLUMN+CELL
r1 column=f1:col1, timestamp=1369947468296, value=v1
r2 column=f2:col2, timestamp=1369947497236, value=v2
r2 column=f2:col3, timestamp=1369947501384, value=v2
2 row(s) in 0.1020 seconds


Get row 'r2' 's columns and values
hbase(main):006:0> get 't1', 'r2'
COLUMN CELL
f2:col2 timestamp=1369947497236, value=v2
f2:col3 timestamp=1369947501384, value=v2
2 row(s) in 0.0320 seconds

No comments:

Post a Comment