HBase表创建、删除、清空
HBase shell窗口進入
執(zhí)行命令hbase shell
| rowkey(行鍵) | product(列簇) | food(列簇) |
| ||
| name(列標(biāo)識符) | price(列標(biāo)識符) | name | price(列標(biāo)識符) | price(列標(biāo)識符) | |
| rowkey001 | ThinkPad E550 | 4199 | orange | 3166 | 6.0 |
| version(版本) | |||||
| 5.0 | |||||
| 5.5 | |||||
| 6.0 | |||||
?
?
HBase表的創(chuàng)建
# 語法:create <table>, {NAME => <family>, VERSIONS => <VERSIONS>}
# 例如:創(chuàng)建表t1,有兩個family name(列簇名字):f1,f2,且版本數(shù)前者為3,后者為1
hbase(main)> create 't1',{NAME => 'f1', VERSIONS => 3},{NAME => 'f2', VERSIONS => 1}
HBase表的刪除
hbase(main)> disable 't1'
hbase(main)> drop 't1'
HBase表的清空
hbase(main)> truncate 't1'
#-----------------------------------------------------------------------------------------------------
例如可能會出現(xiàn)這樣的情況:
ERROR: Table book is enabled. Disable it first.
For usage try 'help "drop"'
Took 0.0092 seconds ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
hbase(main):009:0> disable 'book'
Took 2.4668 seconds ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
hbase(main):010:0> drop "book"
也就是需要先disable然后才能drop
#-----------------------------------------------------------------------------------------------------
drop一個表格后,如果創(chuàng)建同名表格,會發(fā)現(xiàn)舊有的數(shù)據(jù)還在,這是怎么回事?
完整刪除一個表格的步驟如下:
hbase(main):035:0* disable "book"
Took 4.3432 seconds ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
hbase(main):036:0> alter 'book',{NAME=>'columnName', TTL => '1'}
Updating all regions with the new schema...
All regions updated.
Done.
Took 1.9354 seconds ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
hbase(main):037:0> drop "book"
Took 1.3067 seconds ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
hbase(main):038:0>?
hbase(main):039:0*?
hbase(main):040:0*?
hbase(main):041:0*?
hbase(main):042:0* create "book","information"
Created table book
Took 4.3114 seconds ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
=> Hbase::Table - book
hbase(main):043:0> scan "book"
ROW ? ? ? ? ? ? ? ? ? ? ? ? ? COLUMN+CELL ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
0 row(s)
Took 0.0214 seconds ? ? ? ? ? ? ? ? ? ? ? ? ? ??
?
?
轉(zhuǎn)載自:
https://www.cnblogs.com/followees/p/8336071.html
?
總結(jié)
以上是生活随笔為你收集整理的HBase表创建、删除、清空的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Nifi清空Queue操作
- 下一篇: Nifi出现Failed to send