status:查询集群的一些状态
hbase(main):002:0> status
1 active master, 0 backup masters, 1 servers, 0 dead, 3.0000 average load
list : 查看现有的表
hbase(main):003:0> list
TABLE
member
1 row(s) in 0.0390 seconds
create:创建一张表,表名为FileTable ,有两个列簇 fileinfo和saveinfo
hbase(main):004:0> create
create create_namespace
hbase(main):004:0> create 'FlieTable', 'fileinfo','saveinfo'
0 row(s) in 2.2730 seconds
=> Hbase::Table - FlieTable
alert:修改表,新添加一个列簇
hbase(main):009:0> alter 'FlieTable','cf'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.1960 seconds
删除一个列簇
hbase(main):010:0> alter 'FlieTable',{NAME=>'cf',METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 1.9440 seconds
put:往表中添加数据, 表名,rowkey(行的唯一标识),列名称(列簇:列名[如fileinfo:name,直接写name会报错]),值
hbase(main):011:0> put 'FlieTable','rowkey1','fileinfo:name','file.txt'
0 row(s) in 0.0950 seconds
hbase(main):012:0> put 'FlieTable','rowkey1','fileinfo:type','txt'
0 row(s) in 0.0070 seconds
hbase(main):013:0> put 'FlieTable','rowkey1','fileinfo:size','1024'
0 row(s) in 0.0040 seconds
hbase(main):014:0> put 'FlieTable','rowkey1','saveinfo:path','/home'
0 row(s) in 0.0050 seconds
hbase(main):015:0> put 'FlieTable','rowkey1','saveinfo:creator','Tom'
0 row(s) in 0.0100 seconds
count:查询表数据行数
hbase(main):021:0> count 'FlieTable'
2 row(s) in 0.0320 seconds
=> 2
get:查询表数据,表名,rowkey名
hbase(main):022:0> get 'FlieTable','rowkey2'
COLUMN CELL
fileinfo:name timestamp=1535337523427, value=file2.txt
fileinfo:size timestamp=1535337500057, value=1024
fileinfo:type timestamp=1535337510694, value=txt
saveinfo:creator timestamp=1535337481965, value=Tom
saveinfo:path timestamp=1535337490938, value=/home
5 row(s) in 0.0140 seconds
get: 查看指定列簇
hbase(main):024:0> get 'FlieTable','rowkey2','fileinfo'
COLUMN CELL
fileinfo:name timestamp=1535337523427, value=file2.txt
fileinfo:size timestamp=1535337500057, value=1024
fileinfo:type timestamp=1535337510694, value=txt
scan:查询整张表数据
hbase(main):025:0> scan 'FlieTable'
ROW COLUMN+CELL
rowkey1 column=fileinfo:name, timestamp=1535337211558, value=file.txt
rowkey1 column=fileinfo:size, timestamp=1535337252743, value=1024
rowkey1 column=fileinfo:type, timestamp=1535337239752, value=txt
rowkey1 column=saveinfo:creator, timestamp=1535337344582, value=Tom
rowkey1 column=saveinfo:path, timestamp=1535337310728, value=/home
rowkey2 column=fileinfo:name, timestamp=1535337523427, value=file2.txt
rowkey2 column=fileinfo:size, timestamp=1535337500057, value=1024
rowkey2 column=fileinfo:type, timestamp=1535337510694, value=txt
rowkey2 column=saveinfo:creator, timestamp=1535337481965, value=Tom
rowkey2 column=saveinfo:path, timestamp=1535337490938, value=/home
2 row(s) in 0.0220 seconds
scan:查看指定列簇,除了COLUMU,还支持STARTROW='rowkey1' LIMIT,VERSIONS等参数
hbase(main):027:0> scan 'FlieTable',{COLUMN=>'fileinfo:name'}
ROW COLUMN+CELL
rowkey1 column=fileinfo:name, timestamp=1535337211558, value=file.txt
rowkey2 column=fileinfo:name, timestamp=1535337523427, value=file2.txt
2 row(s) in 0.0120 seconds
delete:删除某一行
hbase(main):030:0> delete 'FlieTable','rowkey2','fileinfo:size'
0 row(s) in 0.0230 seconds
deleteall:删除整个rowkey
hbase(main):031:0> deleteall 'FlieTable','rowkey2'
disable:删除表,删除表之前要先禁用表。is_enable/ dis_enable + 表名 查看表是否被启/禁用
hbase(main):032:0> disable 'FlieTable'
drop:表呗禁用之后就能删除了 drop+表名