启动hbase shell
# hbase shell
不需要使用分号,可以直接两个单引号’处理
hbase(main):002:0> list;
hbase(main):003:0* '
hbase(main):004:0' '
TABLE
kylin_metadata
1 row(s) in 0.0130 seconds
=> "\n"
hbase(main):001:0> list
TABLE
kylin_metadata
1 row(s) in 0.5110 seconds
=> ["kylin_metadata"]
创建表,必须指定
hbase(main):017:0> create 'student','base_info'
0 row(s) in 1.4950 seconds
=> Hbase::Table - student
hbase(main):018:0> create 'stu','info','addr'
0 row(s) in 1.2680 seconds
=> Hbase::Table - stu
查看表,
desc 'student'
Table student is ENABLED
student
COLUMN FAMILIES DESCRIPTION
{NAME => 'base_info', 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'}
1 row(s) in 0.0630 seconds
删除,需要先禁止disable操作
hbase(main):021:0> drop 'student'
ERROR: Table student 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):022:0> disable 'student'
0 row(s) in 2.2850 seconds
hbase(main):023:0> drop 'student'
0 row(s) in 1.2840 seconds
查看命名空间
hbase(main):024:0> list_namespace
NAMESPACE
default
hbase
2 row(s) in 0.0520 seconds
创建命名空间
hbase(main):025:0> create_namespace 'bigdata'
0 row(s) in 0.9040 seconds
创建空间的表数据
create 'bigdata:stu','info'
0 row(s) in 1.2770 seconds
=> Hbase::Table - bigdata:stu
删除空间
hbase(main):028:0> drop_namespace 'bigdata
Here is some help for this command:
Drop the named namespace. The namespace must be empty.
hbase(main):030:0> disable 'bigdata:stu'
0 row(s) in 2.2480 seconds
hbase(main):031:0> drop 'bigdata:stu'
0 row(s) in 1.2440 seconds
hbase(main):032:0> drop_namespace 'bigdata'
0 row(s) in 0.8720 seconds