首页 > 代码库 > hbase 基本命令

hbase 基本命令

1、用shell来连接HBase

[root@hbase1 bin]# cd /usr/hadoop/hbase-1.1.7/bin

[root@hbase1 bin]# ./hbase shell


HBase Shell; enter help<RETURN> for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.1.7, re7ee6fa201c4fb1962f8928df3d519b70b4ff717, Fri Oct  7 18:36:27 PDT 2016

hbase(main):001:0> 

2、创建表

hbase(main):001:0> create table1,col1
0 row(s) in 1.4940 seconds

=> Hbase::Table - table1
hbase(main):002:0> 

3、插入记录

hbase(main):003:0> put table1,row2,col1:b,value2
0 row(s) in 0.0130 seconds

4、查看记录(scan)

hbase(main):002:0>  scan table1
 
row2                 column=col1:b, timestamp=1478957314808, value=http://www.mamicode.com/value2      
1 row(s) in 30.4430 seconds

5、 用get查看单行数据

hbase(main):011:0> get table1,row1

COLUMN               CELL                                                     

col1:a               timestamp=1317180621803, value=http://www.mamicode.com/value1                    

1 row(s) in 0.0160 seconds

6、 用disable和drop删除表

hbase(main):017:0> disable table1

0 row(s) in 2.0470 seconds

 

hbase(main):018:0> drop table1

0 row(s) in 0.0960 seconds

 

hbase(main):019:0> list

TABLE                                                                                                                                                   

1 row(s) in 0.0170 seconds

 

hbase 基本命令