创建一个表
hbase(main):001:0> create ‘student‘, ‘name‘ 0 row(s) in 14.0260 seconds => Hbase::Table - student
列出所有表
hbase(main):025:0> list TABLE student student_1 2 row(s) in 0.0270 seconds => ["student", "student_1"]
往表中添加数据
hbase(main):006:0> put ‘student‘, ‘row1‘, ‘name:a‘, ‘zhangxs‘ 0 row(s) in 1.3820 seconds hbase(main):007:0> put ‘student‘, ‘row2‘, ‘name:b‘, ‘li‘ 0 row(s) in 0.0730 seconds
查询表中的数据
hbase(main):008:0> scan ‘student‘ ROW COLUMN+CELL row1 column=name:a, timestamp=1482855835031, value=zhangxs row2 column=name:b, timestamp=1482855883411, value=li 2 row(s) in 0.2530 seconds
查询表中指定行数的数据
hbase(main):009:0> get ‘student‘, ‘roww1‘ COLUMN CELL 0 row(s) in 0.1080 seconds hbase(main):010:0> get ‘student‘, ‘row1‘ COLUMN CELL name:a timestamp=1482855835031, value=zhangxs 1 row(s) in 0.1050 seconds
查询表中指定列的数据
hbase(main):020:0> scan ‘student‘,{COLUMNS=>‘name‘} ROW COLUMN+CELL row1 column=name:a, timestamp=1482855835031, value=zhangxs row2 column=name:b, timestamp=1482855883411, value=li 2 row(s) in 0.1190 seconds
将表治为失效
hbase(main):011:0> disable ‘student‘ 0 row(s) in 2.7450 seconds
当将表设置为失效后,就不能查询该表的数据
hbase(main):014:0> scan ‘student‘ ROW COLUMN+CELL ERROR: student is disabled.
将表设置为生效
hbase(main):015:0> enable ‘student‘ 0 row(s) in 1.3880 seconds
删除表需要先将表设置为disable,再删除
hbase(main):028:0> drop ‘student_1‘ 0 row(s) in 2.4750 seconds
时间: 2024-11-04 03:51:17