Hive系列文章
Hive表的基本操作
Hive中的集合数据类型
Hive动态分区详解
hive中orc格式表的数据导入
Java通过jdbc连接hive
通过HiveServer2访问Hive
SpringBoot连接Hive实现自助取数
hive关联hbase表
Hive udf 使用方法
Hive基于UDF进行文本分词
Hive窗口函数row number的用法
数据仓库之拉链表
- 创建表
create table语句遵从sql语法习惯,只不过Hive的语法更灵活。例如,可以定义表的数据文件存储位置,使用的存储格式等。
create table if not exists test.user1(
name string comment ‘name’,
salary float comment ‘salary’,
address struct<country:string, city:string> comment ‘home address’
)
comment ‘description of the table’
partitioned by (age int)
row format delimited fields terminated by ‘\t’
stored as orc;
SQL
没有指定external关键字,则为管理表,跟mysql一样,if not exists如果表存在则不做操作,否则则新建表。comment可以为其做注释,分区为age年龄,列之间分隔符是\t,存储格式为列式存储orc,存储位置为默认位置,即参数hive.metastore.warehouse.dir(默认:/user/hive/warehouse)指定的hdfs目录。
2. 拷贝表
使用like可以拷贝一张跟原表结构一样的空表,里面是没有数据的。