hbase操作语句-03.docx

1、创建一个名为 test 的表,这个表只有一个 column family  cf

hbase(main):003:0> create   'test','cf'

0 row(s) in 3.7990 seconds

 2列出所有的表来检查创建情况

hbase(main):006:0> list

TABLE                                                                            

test                                                                             

1 row(s) in 0.0380 seconds

 3插入一行,行keyrow1, 列为 cf:a 值是 value1

Hbase中的列是由 column family前缀和列的名字组成的,以冒号间隔。例如这一行的列名就是a.

hbase(main):007:0> put 'test', 'row1',   'cf:a', 'value1'

0 row(s) in 0.1230 seconds

 

hbase(main):008:0>

hbase(main):010:0> put 'test', 'row2',   'cf:b', 'value2'

0 row(s) in 0.0160 seconds

hbase(main):011:0> put 'test', 'row3',   'cf:b', 'value3'

0 row(s) in 0.0070 seconds

 4检查插入情况

1)、Scan这个表

hbase(main):012:0> scan 'test'

ROW                     COLUMN+CELL                                                

 row1                 column=cf:a,   timestamp=1433923693891, value=value1         

 row2                 column=cf:b,   timestamp=1433923868853, value=value2         

 row3                 column=cf:b,   timestamp=1433923881677, value=value3         

3 row(s) in 0.0820 seconds

 

hbase(main):013:0>

 2)、Get一行

hbase(main):013:0> get 'test', 'row1'

COLUMN                  CELL                                                       

 cf:a                 timestamp=1433923693891,   value=value1                    

1 row(s) in 0.0190 seconds

 3)、disable drop 这张表

disable drop 这张表,可以清除你刚刚的操作。

hbase(main):014:0> scan 'test'

ROW                     COLUMN+CELL                                                

 row1                 column=cf:a,   timestamp=1433923693891, value=value1         

 row2                 column=cf:b,   timestamp=1433923868853, value=value2         

 row3                 column=cf:b,   timestamp=1433923881677, value=value3         

3 row(s) in 0.0270 seconds

 

hbase(main):015:0> list

TABLE                                                                            

test                                                                            

1 row(s) in 0.0280 seconds

 

hbase(main):016:0> disable 'test'

0 row(s) in 1.1470 seconds

 

hbase(main):017:0> scan 'test'

ROW                     COLUMN+CELL                                                

 

ERROR:   org.apache.hadoop.hbase.DoNotRetryIOException: test is disabled.

hbase(main):018:0> list

TABLE                                                                             

test                                                                             

1 row(s) in 0.0240 seconds

 

hbase(main):019:0>

 

hbase(main):019:0> drop 'test'

0 row(s) in 1.0980 seconds

 

hbase(main):020:0> list

TABLE                                                                            

0 row(s) in 0.0180   seconds

 

hbase(main):021:0>

 

 


你可能感兴趣的:(hbase操作语句-03.docx)