输入:hbase shell
hbase(main):001:0> help
hbase(main):002:0> list_namespace_tables 'hbase'
hbase(main):010:0> create 'user', 'info', 'data'
或者
hbase(main):010:0> create 'user1', {NAME => 'info', VERSIONS => '3'},{NAME => 'data'}
向user表中插入信息,row key为rk0001,列族info中添加名为name的列,值为zhangsan
hbase(main):011:0> put 'user', 'rk0001', 'info:name', 'zhangsan'
向user表中插入信息,row key为rk0001,列族info中添加名为gender的列,值为female
hbase(main):012:0> put 'user', 'rk0001', 'info:gender', 'female'
向user表中插入信息,row key为rk0001,列族info中添加名为age的列,值为20
hbase(main):013:0> put 'user', 'rk0001', 'info:age', 20
向user表中插入信息,row key为rk0001,列族data中添加名为pic的列,值为picture
hbase(main):014:0> put 'user', 'rk0001', 'data:pic', 'picture'
hbase(main):015:0> get 'user', 'rk0001'
hbase(main):016:0> get 'user', 'rk0001', 'info'
hbase(main):017:0> get 'user', 'rk0001', 'info:name', 'info:age'
hbase(main):018:0> get 'user', 'rk0001', 'info', 'data'
或者你也可以这样写
hbase(main):019:0> get 'user', 'rk0001', {COLUMN => ['info', 'data']}
或者你也可以这样写,也行
hbase(main):020:0> get 'user', 'rk0001', {COLUMN => ['info:name', 'data:pic']}
hbase(main):030:0> get 'user', 'rk0001', {FILTER => "ValueFilter(=, 'binary:zhangsan')"}
hbase(main):031:0> get 'user', 'rk0001', {FILTER => "QualifierFilter(=,'substring:a')"}
继续插入一批数据
hbase(main):032:0> put 'user', 'rk0002', 'info:name', 'fanbingbing'
hbase(main):033:0> put 'user', 'rk0002', 'info:gender', 'female'
hbase(main):034:0> put 'user', 'rk0002', 'info:nationality', '中国'
hbase(main):035:0> get 'user', 'rk0002', {FILTER => "ValueFilter(=, 'binary:中国')"}
hbase(main):032:0> scan 'user'
scan 'user', {COLUMNS => 'info'}
scan 'user', {COLUMNS => 'info', RAW => true, VERSIONS => 5}
scan 'user', {COLUMNS => 'info', RAW => true, VERSIONS => 3}
scan 'user', {COLUMNS => ['info', 'data']}
scan 'user', {COLUMNS => 'info:name'}
scan 'user', {COLUMNS => ['info:name', 'data:pic']}
scan 'user', {COLUMNS => 'info:name', VERSIONS => 5}
scan 'user', {COLUMNS => ['info', 'data'], FILTER => "(QualifierFilter(=,'substring:a'))"}
scan 'user', {COLUMNS => 'info', STARTROW => 'rk0001', ENDROW => 'rk0003'}
scan 'user',{FILTER=>"PrefixFilter('rk')"}
scan 'user', {TIMERANGE => [1392368783980, 1392380169184]}
hbase(main):050:0> alter 'user', NAME => 'info', VERSIONS => 5
hbase(main):045:0> delete 'user', 'rk0001', 'info:name'
delete 'user', 'rk0001', 'info:name', 1392383705316
alter 'user', NAME => 'info', METHOD => 'delete'
或 alter 'user', 'delete' => 'info'
hbase(main):017:0> truncate 'user'
hbase(main):049:0> disable 'user'
hbase(main):050:0> drop 'user'
(注意:如果直接drop表,会报错:Drop the named table. Table must first be disabled)
hbase(main):053:0> count 'user'
.8.5 删除表
hbase(main):049:0> disable 'user'
hbase(main):050:0> drop 'user'
(注意:如果直接drop表,会报错:Drop the named table. Table must first be disabled)
hbase(main):053:0> count 'user'