在HBase中,namespace命名空間指對一組表的邏輯分組,相似於數據庫,便於對錶在業務上劃分數據庫
hbase(main):224:0> list_namespace
NAMESPACE
default
hbase
2 row(s)
Took 0.2533 secondsexpress
hbase(main):223:0> help "namespace"apache
Command: alter_namespace Alter namespace properties.oop
To add/modify a property:spa
hbase> alter_namespace 'ns1', {METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'}hadoop
To delete a property:ci
hbase> alter_namespace 'ns1', {METHOD => 'unset', NAME=>'PROPERTY_NAME'}rem
Command: create_namespace Create namespace; pass namespace name, and optionally a dictionary of namespace configuration. Examples:io
hbase> create_namespace 'ns1' hbase> create_namespace 'ns1', {'PROPERTY_NAME'=>'PROPERTY_VALUE'}table
Command: describe_namespace Describe the named namespace. For example: hbase> describe_namespace 'ns1'
Command: drop_namespace Drop the named namespace. The namespace must be empty.
Command: list_namespace List all namespaces in hbase. Optional regular expression parameter could be used to filter the output. Examples:
hbase> list_namespace hbase> list_namespace 'abc.*'
Command: list_namespace_tables List all tables that are members of the namespace. Examples:
hbase> list_namespace_tables 'ns1'
建立命名空間
hbase(main):226:0> create_namespace 'testdb'
Took 2.1094 seconds
列出全部命名空間
hbase(main):227:0> list_namespace
NAMESPACE
default
hbase
testdb
3 row(s)
Took 0.0217 seconds
在namespace建立表
hbase(main):229:0> create 'testdb:mytable','basicinfo'
Created table testdb:mytable
Took 2.3445 seconds
=> Hbase::Table - testdb:mytable
查看命名空間下的表
hbase(main):238:0> list_namespace_tables 'testdb'
TABLE
mytable
1 row(s)
Took 0.0139 seconds
=> ["mytable"]
刪除命名空間
hbase(main):239:0> drop_namespace 'testdb'
ERROR: org.apache.hadoop.hbase.constraint.ConstraintException: Only empty namespaces can be removed. Namespace testdb has 1 tables
提示只有空的命名空間能夠刪除,刪除命名空間前。須要先刪除命名空間的表
hbase(main):241:0> disable 'testdb:mytable'Took 0.7931 seconds hbase(main):242:0> drop 'testdb:mytable'Took 0.9203 seconds hbase(main):243:0> drop_namespace 'testdb'Took 0.5726 seconds