--查询禁用状态
hbase(main):024:0> is_disabled 'resume'
false
0 row(s) in 0.4930 seconds
hbase(main):021:0> is_enabled 'resume'
true
0 row(s) in 0.2450 seconds
--删除表
hbase(main):015:0> create 't1','f1'
0 row(s) in 15.3730 seconds
hbase(main):016:0> disable 't1'
0 row(s) in 6.4840 seconds
hbase(main):017:0> drop 't1'
0 row(s) in 7.3730 seconds
--查询表是否存在
hbase(main):018:0> exists 'resume'
Table resume does exist
0 row(s) in 2.3900 seconds
hbase(main):019:0> exists 't1'
Table t1 does not exist
0 row(s) in 1.3270 seconds
--插入数据
put 'resume','lichangzai','binfo:age','1980-1-1'
put 'resume','lichangzai','binfo:sex','man'
put 'resume','lichangzai','edu:mschool','rq no.1'
put 'resume','lichangzai','edu:university','qhddx'
put 'resume','lichangzai','work:company1','12580'
put 'resume','lichangzai','work:company2','china mobile'
put 'resume','lichangzai','binfo:site','blog.csdn.net/lichangzai'
put 'resume','lichangzai','binfo:mobile','13712345678'
put 'resume','changfei','binfo:age','1986-2-1'
put 'resume','changfei','edu:university','bjdx'
put 'resume','changfei','work:company1','LG'
put 'resume','changfei','binfo:mobile','13598765401'
put 'resume','changfei','binfo:site','hi.baidu/lichangzai'
--获取一行键的所有数据
hbase(main):014:0> get 'resume','lichangzai'
COLUMN CELL
binfo:age timestamp=1356485720612, value=1980-1-1
binfo:mobile timestamp=1356485865523, value=13712345678
binfo:sex timestamp=1356485733603, value=man
binfo:site timestamp=1356485859806, value=blog.csdn.net/lichangzai
edu:mschool timestamp=1356485750361, value=rq no.1
edu:university timestamp=1356485764211, value=qhddx
work:company1 timestamp=1356485837743, value=12580
work:company2 timestamp=1356485849365, value=china mobile
8 row(s) in 2.1090 seconds
注意:必须通过行键Row Key来查询数据
--获取一个行键,一个列族的所有数据
hbase(main):015:0> get 'resume','lichangzai','binfo'
COLUMN CELL
binfo:age timestamp=1356485720612, value=1980-1-1
binfo:mobile timestamp=1356485865523, value=13712345678
binfo:sex timestamp=1356485733603, value=man
binfo:site timestamp=1356485859806, value=blog.csdn.net/lichangzai
4 row(s) in 1.6010 seconds
--获取一个行键,一个列族中一个列的所有数据
hbase(main):017:0> get 'resume','lichangzai','binfo:sex'
COLUMN CELL
binfo:sex timestamp=1356485733603, value=man
1 row(s) in 0.8980 seconds
--更新一条记录
hbase(main):018:0> put 'resume','lichangzai','binfo:mobile','13899999999'
0 row(s) in 1.7640 seconds
hbase(main):019:0> get 'resume','lichangzai','binfo:mobile'
COLUMN CELL
binfo:mobile timestamp=1356486691591, value=13899999999
1 row(s) in 1.5710 seconds
注意:更新实质就是插入一条带有时间戳的记录,get查询时只显示最新时间的记录
--通过timestamp来获取数据
------查询最新的时间戳的数据
hbase(main):020:0> get 'resume','lichangzai',{COLUMN=>'binfo:mobile',TIMESTAMP=>1356486691591}
COLUMN CELL
binfo:mobile timestamp=1356486691591, value=13899999999
1 row(s) in 0.4060 seconds
------查之前(即删除)时间戳的数据
hbase(main):021:0> get 'resume','lichangzai',{COLUMN=>'binfo:mobile',TIMESTAMP=>1356485865523}
COLUMN CELL
binfo:mobile timestamp=1356485865523, value=13712345678
1 row(s) in 0.7780 seconds
--全表扫描
hbase(main):022:0> scan 'resume'
ROW COLUMN+CELL
changfei column=binfo:age, timestamp=1356485874056, value=1986-2-1
changfei column=binfo:mobile, timestamp=1356485897477, value=13598765401
changfei column=binfo:site, timestamp=1356485906106, value=hi.baidu/lichangzai
changfei column=edu:university, timestamp=1356485880977, value=bjdx
changfei column=work:company1, timestamp=1356485888939, value=LG
lichangzai column=binfo:age, timestamp=1356485720612, value=1980-1-1
lichangzai column=binfo:mobile, timestamp=1356486691591, value=13899999999
lichangzai column=binfo:sex, timestamp=1356485733603, value=man
lichangzai column=binfo:site, timestamp=1356485859806, value=blog.csdn.net/lichangzai
lichangzai column=edu:mschool, timestamp=1356485750361, value=rq no.1
lichangzai column=edu:university, timestamp=1356485764211, value=qhddx
lichangzai column=work:company1, timestamp=1356485837743, value=12580
lichangzai column=work:company2, timestamp=1356485849365, value=china mobile
2 row(s) in 3.6300 seconds
--删除指定行键的列族字段
hbase(main):023:0> put 'resume','changfei','binfo:sex','man'
0 row(s) in 1.2630 seconds
hbase(main):024:0> delete 'resume','changfei','binfo:sex'
0 row(s) in 0.5890 seconds
hbase(main):026:0> get 'resume','changfei','binfo:sex'
COLUMN CELL
0 row(s) in 0.5560 seconds
--删除整行
hbase(main):028:0> create 't1','f1','f2'
0 row(s) in 8.3950 seconds
hbase(main):029:0> put 't1','a','f1:col1','xxxxx'
0 row(s) in 2.6790 seconds
hbase(main):030:0> put 't1','a','f1:col2','xyxyx'
0 row(s) in 0.5130 seconds
hbase(main):031:0> put 't1','b','f2:cl1','ppppp'
0 row(s) in 1.2620 seconds
hbase(main):032:0> deleteall 't1','a'
0 row(s) in 1.2030 seconds
hbase(main):033:0> get 't1','a'
COLUMN CELL
0 row(s) in 0.8980 seconds
--查询表中有多少行
hbase(main):035:0> count 'resume'
2 row(s) in 2.8150 seconds
hbase(main):036:0> count 't1'
1 row(s) in 0.9500 seconds
--清空表
hbase(main):037:0> truncate 't1'
Truncating 't1' table (it may take a while):
- Disabling table...
- Dropping table...
- Creating table...
0 row(s) in 21.0060 seconds
注意:Truncate表的处理过程:由于Hadoop的HDFS文件系统不允许直接修改,所以只能先删除表在重新创建已达到清空表的目的