hive -- 外部表、内部表、临时表

1.外部表

关键字:EXTERNAL

外部表创建时需要指定LOCATION

删除外部表时,数据不被删除

CREATE EXTERNAL TABLE page_view(viewTime INT, userid BIGINT,
     page_url STRING, referrer_url STRING,
     ip STRING COMMENT 'IP Address of the User',
     country STRING COMMENT 'country of origination')
 COMMENT 'This is the staging page view table'
 ROW FORMAT DELIMITED FIELDS TERMINATED BY '\054'
 STORED AS TEXTFILE
 LOCATION '<hdfs_location>';

2.内部表

3.临时表

Hive 0.14.0及以上

表只对当前session有效,session退出后,表自动删除。

语法:

CREATE TEMPORARY TABLE ...

注意点:

1、如果创建的临时表表名已存在,那么当前session引用到该表名时实际用的是临时表,只有drop或rename临时表名才能使用原始表

2、临时表限制:不支持分区字段和创建索引

Hive1.1开始临时表可以存储在内存或SSD,使用hive.exec.temporary.table.storage参数进行配置,该参数有三种取值:memory、ssd、default。

猜你喜欢

转载自blog.csdn.net/qq_38723677/article/details/82703869