alter
Definition
Allows to add, modify or delete column families and change table configuration options. Column families are defined in the same way, as in the case of create command. Each column family specification can be either a simple string or a dictionary with mandatory NAME
attribute.
Usage
-
Adding or modifying a column family:
alter '[<namespace_name>:]<table_name>', '<column_family>' | {NAME => '<column_family>'[, <cf_attribute_name> => <cf_attribute_value>,...]}[,...]
-
Deleting a column family:
-
Method 1:
alter '[<namespace_name>:]<table_name>', NAME => '<column_family>', METHOD => 'delete'
-
Method 2:
alter '[<namespace_name>:]<table_name>', 'delete' => '<column_family>'
-
-
Setting table-scope parameters:
alter '[<namespace_name>:]<table_name>', <table_attribute_name> => <table_attribute_value>[,...]
-
Resetting table-scope parameters:
alter '[<namespace_name>:]<table_name>', METHOD => 'table_att_unset', NAME => '<table_attribute_name>'
-
Setting configuration options:
alter '[<namespace_name>:]<table_name>', CONFIGURATION => {'<conf_attribute_name>' => <conf_attribute_value>[,...]}
-
Resetting configuration options:
alter '[<namespace_name>:]<table_name>', METHOD => 'table_conf_unset', NAME => '<conf_attribute_name>'
TIP
There could be more than one alteration in one command.
|
Parameter | Description |
---|---|
namespace_name |
A namespace name |
table_name |
A table name |
column_family |
A column family name |
cf_attribute_name |
A column family attribute name |
cf_attribute_value |
A value of the specified column family attribute |
table_attribute_name |
A table-scope attribute name |
table_attribute_value |
A value of the specified table-scope attribute |
conf_attribute_name |
A configuration attribute name |
conf_attribute_value |
A value of the specified configuration attribute |
Examples
Modifying a column family
hbase(main):001:0> describe 't1' Table t1 is ENABLED t1 COLUMN FAMILIES DESCRIPTION {NAME => 'cf1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} {NAME => 'cf2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} 2 row(s) Took 0.5144 seconds hbase(main):002:0> alter 't1', {NAME => 'cf1', VERSIONS => 10} Updating all regions with the new schema... 1/1 regions updated. Done. Took 2.5811 seconds hbase(main):003:0> describe 't1' Table t1 is ENABLED t1 COLUMN FAMILIES DESCRIPTION {NAME => 'cf1', VERSIONS => '10', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} {NAME => 'cf2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} 2 row(s) Took 0.0206 seconds
Adding a new column family
hbase(main):004:0> alter 't1', 'cf3' Updating all regions with the new schema... 1/1 regions updated. Done. Took 2.1848 seconds hbase(main):005:0> describe 't1' Table t1 is ENABLED t1 COLUMN FAMILIES DESCRIPTION {NAME => 'cf1', VERSIONS => '10', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} {NAME => 'cf2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'fa lse', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} {NAME => 'cf3', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} 3 row(s) Took 0.0183 seconds
Deleting a column family
hbase(main):007:0> alter 't1', NAME => 'cf3', METHOD => 'delete' Updating all regions with the new schema... 1/1 regions updated. Done. Took 2.5314 seconds hbase(main):008:0> describe 't1' Table t1 is ENABLED t1 COLUMN FAMILIES DESCRIPTION {NAME => 'cf1', VERSIONS => '10', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} {NAME => 'cf2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLICATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'} 2 row(s) Took 0.0175 seconds
Setting a table-scope parameter
hbase(main):001:0> alter 't1', MAX_FILESIZE => '134217728' Updating all regions with the new schema... 1/1 regions updated. Done. Took 2.9316 seconds
Resetting a table-scope parameter
hbase(main):002:0> alter 't1', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE' Updating all regions with the new schema... 1/1 regions updated. Done. Took 2.3027 seconds