创建表
hbase shell> create \'mytable\',\'col1\',\'col2\' //建表语句 create \'表名\',\'列簇名\',\'列簇名\',\'列簇名\' hbase shell> create \'mytable\',{NAME => \'info\',versionS => 1, TTL => 214783647, BLOCKCACHE => false,IN_MEMORY=>false},{NAME=>\'tempData\',VERSIONS=>1,TTL=>259200,BLOCKCACHE=>false,IN_MEMORY=>false}
查询
//列出所有表 hbase shell> list //查看表结构 hbase shell> describe \'mytable\' //查看表的结构构造
修改表结构
//修改表的结构..删除某列簇 //删除表中的列簇 注: 要求先disable 表,,修改后enable表 //请严格区分大小写 hbase shell> disable \'mytable\' hbase shell> alter \'mytable\',{NAME=>\'ct\',METHOD=>\'delete\'} hbase shell> enable \'mytable\' //修改表结构 新增一个列簇 //请严格区分大小写 hbase shell> disable \'mytable\' hbase shell> alter \'mytable\',{NAME=>\'columnsfamilyName\',VERSIONS=>1} hbase shell> enable \'mytable\'
删除
//删除表 hbase shell> disable \'mytable\' //先禁用表 分离 hbase shell> drop \'table\' //删除表
表重命名
hbase shell> disable \'mytable\' //停用表 hbase shell> snapshot \'mytable\', \'tableSnapshot\' //为表创建快照..这时还没有复制数据 hbase shell> clone_snapshot \'tableSnapshot\', \'newTableName\' //根据某个快照而创建新表..此时复制数据 hbase shell> delete_snapshot \'tableSnapshot\' //删除快照 hbase shell> drop \'mytable\' //删除原来的表