Row key
|
personal data
|
professional data
|
|
|
|
|
|
|
hbase(main):001:0> create 'emp','personal data','professional data'
0 row(s) in 1.4790 seconds
=> Hbase::Table - emp
hbase(main):002:0> exists 'emp'
Table emp does exist
0 row(s) in 0.1230 seconds
hbase(main):003:0> desc 'emp'
Table emp is ENABLED
emp
COLUMN FAMILIES DESCRIPTION
{NAME => 'personal data', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE
=> '0'}
{NAME => 'professional data', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_S
COPE => '0'}
2 row(s) in 0.0430 seconds
hbase(main):004:0> alter 'emp', NAME => 'personal data', VERSIONS => 5
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.9390 seconds
hbase(main):005:0> desc 'emp'
Table emp is ENABLED
emp
COLUMN FAMILIES DESCRIPTION
{NAME => 'personal data', BLOOMFILTER => 'ROW', VERSIONS => '5', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE
=> '0'}
{NAME => 'professional data', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_S
COPE => '0'}
2 row(s) in 0.0240 seconds
hbase(main):005:0> desc 'emp'
Table emp is ENABLED
emp
COLUMN FAMILIES DESCRIPTION
{NAME => 'personal data', BLOOMFILTER => 'ROW', VERSIONS => '5', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE
=> '0'}
{NAME => 'professional data', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_S
COPE => '0'}
2 row(s) in 0.0240 seconds
hbase(main):007:0> alter 'emp','delete' => 'personal data'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.9460 seconds
hbase(main):008:0> desc 'emp'
Table emp is ENABLED
emp
COLUMN FAMILIES DESCRIPTION
{NAME => 'professional data', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_S
COPE => '0'}
1 row(s) in 0.0270 seconds
hbase(main):016:0> drop 'emp'
ERROR: Table emp is enabled. Disable it first.
Here is some help for this command:
Drop the named table. Table must first be disabled:
hbase> drop 't1'
hbase> drop 'ns1:t1'
hbase(main):017:0>
hbase(main):018:0> disable 'emp'0 row(s) in 1.4580 secondshbase(main):019:0> drop 'emp'0 row(s) in 0.3060 seconds
使用exists 命令验证表是否被删除。
hbase(main):020:0> exists 'emp'Table emp does not exist0 row(s) in 0.0730 seconds
hbase(main):079:0> list 'test0.*'
TABLE
test001
test010
test011
3 row(s) in 0.0100 seconds
=> ["test001", "test010", "test011"]
所有这些表以字母test0开始。首先使用disable_all命令禁用所有这些表如下所示。
hbase(main):080:0> disable_all 'test0.*'
test001
test010
test011
Disable the above 3 tables (y/n)?
y
3 tables successfully disabled
hbase(main):081:0> drop_all 'test0.*'
test001
test010
test011
Drop the above 3 tables (y/n)?
y
3 tables successfully disabled
hbase(main):005:0> put 'emp','1','personal data:name','raju'
0 row(s) in 0.6600 seconds
hbase(main):006:0> put 'emp','1','personal data:city','hyderabad'
0 row(s) in 0.0410 seconds
hbase(main):007:0> put 'emp','1','professional data:designation','manager'
0 row(s) in 0.0240 seconds
hbase(main):007:0> put 'emp','1','professional data:salary','50000'
0 row(s) in 0.0240 seconds
hbase(main):033:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526107123317, value=hyderabad
1 column=personal data:name, timestamp=1526107114531, value=raju
1 column=professional data:designation, timestamp=1526107149015, value=manager
1 column=professional data:salary, timestamp=1526107161142, value=50000
1 row(s) in 0.0420 seconds
hbase(main):038:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526107123317, value=hyderabad
1 column=personal data:name, timestamp=1526107114531, value=raju
1 column=professional data:designation, timestamp=1526107149015, value=manager
1 column=professional data:salary, timestamp=1526107161142, value=50000
1 row(s) in 0.0190 seconds
hbase(main):039:0> put 'emp','1','personal data:name','Delhi'
0 row(s) in 0.0050 seconds
hbase(main):040:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526107123317, value=hyderabad
1 column=personal data:name, timestamp=1526107469019, value=Delhi
1 column=professional data:designation, timestamp=1526107149015, value=manager
1 column=professional data:salary, timestamp=1526107161142, value=50000
1 row(s) in 0.0120 seconds
hbase(main):041:0> get 'emp','1'
COLUMN CELL
personal data:city timestamp=1526107123317, value=hyderabad
personal data:name timestamp=1526107469019, value=Delhi
professional data:designation timestamp=1526107149015, value=manager
professional data:salary timestamp=1526107161142, value=50000
4 row(s) in 0.0370 seconds
hbase(main):043:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526107123317, value=hyderabad
1 column=personal data:name, timestamp=1526107469019, value=Delhi
1 column=professional data:designation, timestamp=1526107149015, value=manager
1 column=professional data:salary, timestamp=1526107161142, value=50000
1 row(s) in 0.0230 seconds
hbase(main):044:0> get 'emp', '1', {COLUMN=>'personal data:name'}
COLUMN CELL
personal data:name timestamp=1526107469019, value=Delhi
1 row(s) in 0.0110 seconds
hbase(main):043:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526107123317, value=hyderabad
1 column=personal data:name, timestamp=1526107469019, value=Delhi
1 column=professional data:designation, timestamp=1526107149015, value=manager
1 column=professional data:salary, timestamp=1526107161142, value=50000
1 row(s) in 0.0230 seconds
hbase(main):044:0> get 'emp', '1', {COLUMN=>'personal data:name'}
COLUMN CELL
personal data:name timestamp=1526107469019, value=Delhi
1 row(s) in 0.0110 seconds
hbase(main):045:0> delete 'emp', '1', 'personal data:city'
0 row(s) in 0.0470 seconds
hbase(main):046:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:name, timestamp=1526107469019, value=Delhi
1 column=professional data:designation, timestamp=1526107149015, value=manager
1 column=professional data:salary, timestamp=1526107161142, value=50000
1 row(s) in 0.0210 seconds
hbase(main):047:0> deleteall 'emp','1'
0 row(s) in 0.0150 seconds
使用scan命令验证表。表被删除后的快照如下。
hbase(main):048:0> scan 'emp'
ROW COLUMN+CELL
0 row(s) in 0.0220 seconds
hbase(main):062:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526108340886, value=hyderabad
1 column=personal data:name, timestamp=1526108331176, value=raju
1 column=professional data:designation, timestamp=1526108351404, value=manager
1 column=professional data:salary, timestamp=1526108361753, value=50000
1 row(s) in 0.0160 seconds
hbase(main):063:0> count 'emp'
1 row(s) in 0.0060 seconds
=> 1
增加两行之后,会变成3行。
hbase(main):064:0> put 'emp','2','professional data:designation','manager'
0 row(s) in 0.0080 seconds
hbase(main):065:0> put 'emp','3','professional data:designation','manager'
0 row(s) in 0.0570 seconds
hbase(main):066:0> count 'emp'
3 row(s) in 0.0180 seconds
=> 3
hbase(main):067:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526108340886, value=hyderabad
1 column=personal data:name, timestamp=1526108331176, value=raju
1 column=professional data:designation, timestamp=1526108351404, value=manager
1 column=professional data:salary, timestamp=1526108361753, value=50000
2 column=professional data:designation, timestamp=1526108497801, value=manager
3 column=professional data:designation, timestamp=1526108507588, value=manager
3 row(s) in 0.0090 seconds
hbase(main):067:0> scan 'emp'
ROW COLUMN+CELL
1 column=personal data:city, timestamp=1526108340886, value=hyderabad
1 column=personal data:name, timestamp=1526108331176, value=raju
1 column=professional data:designation, timestamp=1526108351404, value=manager
1 column=professional data:salary, timestamp=1526108361753, value=50000
2 column=professional data:designation, timestamp=1526108497801, value=manager
3 column=professional data:designation, timestamp=1526108507588, value=manager
3 row(s) in 0.0090 seconds
hbase(main):068:0> truncate 'emp'
Truncating 'emp' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 3.4100 seconds
hbase(main):069:0> scan 'emp'
ROW COLUMN+CELL
0 row(s) in 0.1370 seconds