启动hbase shell
./bin/hbase shell
1、创建表,查看表
create 'tableName', 'familykey1','familykey2',.... eg. create 'student','info','course'
list #查看表
2、查看表信息
desc 'student'
3、 修改表结构
alter 'student',{'NAME'=>'course','VERSIONS'=>'3'}
4、insert数据到表中
table-->student rowkey-->201601 familykey:column-->info:name 4:timestamp put 'tableName' ,'rowkey','familykey:column' ,'columnValue',timestamp eg. put 'student','201601','info:name','liu',4 put 'student','201601','info:age',15 put 'student','201601','info:sex','nv' put 'student','201601','info:dept','PE'
5、获取数据
get 'tableName','rowkey' eg. get 'student','201601' #获取student表中rowkey为201601的所有列族数据 get 'student','201601','info:name' #获取student表中rowkey为201601且info列族中name的值
6、更新数据(和插入数据一样,只是少了timestamp)
put 'tableName','rowkey','familykey:column' , 'columnValue'
eg.
put 'student','201601','info:name','yangwj'
7、使用scan进行查询
scan 'student',{COLUMN => 'info:dept'} #查询student表中所有列为info:dept的值
scan 'student',FILTER=>"RowFilter(=,'substring:2')" ###?????
8、表的快照
snapshot 'student','stu_snap' #创建表的快照 list_snapshots #显示所有快照表 clone_snapshot 'stu_snap','stu_info' #克隆快照从而生成新的表 delete_snapshot 'stu_snap' #删除快照
9、删除表 (先禁用表再删除)
disable 'student' #禁用表 is_disabled 'student' #查看表是否被禁用 true:禁用 drop 'student' #删除表
10、总结
完毕!