安装好hbase后,执行hbase shell,进入hbase shell命令行:
1,建立一个表student:
hbase(main):030:0> create 'student','grade','course'
0 row(s) in 0.6060 seconds
hbase(main):031:0>
2,查看hbase中表,有scores、student、test三个表:
hbase(main):031:0> list
TABLE
scores
student
test
3 row(s) in 0.0340 seconds
3,查看student表构造:
hbase(main):032:0> describe 'student'
DESCRIPTION ENABLED
{NAME => 'student', FAMILIES => [{NAME => 'course', BLOOMFILTER => 'NONE', R true
EPLICATION_SCOPE => '0', COMPRESSION => 'NONE', VERSIONS => '3', TTL => '214
7483647', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'},
{NAME => 'grade', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', COMPRESS
ION => 'NONE', VERSIONS => '3', TTL => '2147483647', BLOCKSIZE => '65536', I
N_MEMORY => 'false', BLOCKCACHE => 'true'}]}
1 row(s) in 0.1080 seconds
4,加入一行,Ann的grade是2
hbase(main):033:0> put 'student','Ann','grade:','2'
0 row(s) in 0.0480 seconds
5,给Ann的这行,cource列族加入math 87
hbase(main):034:0> put 'student','Ann','course:math','87'
0 row(s) in 0.0580 seconds
6,给Ann的这行,cource的列族加入art 90
hbase(main):035:0> put 'student','Ann','course:art','90'
0 row(s) in 0.0470 seconds
7,查看student表中,Ann的数据
hbase(main):038:0> get 'student','Ann'
COLUMN CELL
course:art timestamp=1398771395590, value=90
course:math timestamp=1398771275653, value=87
grade: timestamp=1398771189743, value=2
3 row(s) in 0.0490 seconds
8,查看student表中所有数据
hbase(main):039:0> scan 'student'
ROW COLUMN+CELL
Amy column=course:art, timestamp=1398771472502, value=86
Amy column=course:math, timestamp=1398771483251, value=76
Ann column=course:art, timestamp=1398771395590, value=90
Ann column=course:math, timestamp=1398771275653, value=87
Ann column=grade:, timestamp=1398771189743, value=2
2 row(s) in 0.0680 seconds
9,删除一个表
disable 'student'
drop 'student'