语法:create <table>, {NAME =><family>, VERSIONS =><VERSIONS>}
例如:创建表t1,有两个family name:f1,f2,且版本数前者为3,后者为1
disable表
drop表
1. 启动hive,并连接到hbase./hive --auxpath /opt/apache/hive-0.12.0-bin/lib/hive_hbase-handler-
2. 创建内表
CREATE TABLE hive_123(word string, count bigint)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")
TBLPROPERTIES ("hbase.table.name" = "hive_123")
执行这条命令后,hive将会在hbase上创建表"hive_123",hive列与hbase列的映射关系为:
word字段为hbase表的rowkey,count字段则为cf1:val即column family为cf1,qualifier为val
3. 创建外表
CREATE EXTERNAL TABLE hive_vv(key string, sip string, count int)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf0:sip,cf1:count")
TBLPROPERTIES ("hbase.table.name" = "hive_vv")
创建一个hive外表,将名为hive_w的hbase表识别到hive中。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)