hive中的外表EXTERNAL TABLE
来源:互联网 发布:台湾代理ip地址和端口 编辑:程序博客网 时间:2024/04/28 14:46
原文:http://www.oratea.net/?p=489
在hive中,外表是个很重要的组成部分,通过外表可以很方便进行数据的共享。
因为普通的表会将数据文件拷贝自己的目录下,这样想要分享数据只能保存多份数据。
但是外表很好的解决了这个问题。
CREATE EXTERNAL TABLE sunwg_test09(id INT, name string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘\t’
LOCATION ‘/sunwg/test08′;
上面的语句创建了一张名字为sunwg_test09的外表,该表有id和name两个字段,
字段的分割符为tab,文件的数据文件夹为/sunwg/test08
hive> select * from sunwg_test09;
OK
100 tom
101 mary
102 tim
103 kate
104 jone
Time taken: 1.237 seconds
可以查询到sunwg_test09中的数据。
在当前用户hive的根目录下找不到sunwg_test09文件夹。
此时hive将该表的数据文件信息保存到metadata数据库中。
mysql> select * from TBLS where TBL_NAME=’sunwg_test09′;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 16
Current database: hjl
+——–+————-+——-+——————+——-+———–+——-+—————-+—————-+——————–+——————–+
| TBL_ID | CREATE_TIME | DB_ID | LAST_ACCESS_TIME | OWNER | RETENTION | SD_ID | TBL_NAME | TBL_TYPE | VIEW_EXPANDED_TEXT | VIEW_ORIGINAL_TEXT |
+——–+————-+——-+——————+——-+———–+——-+—————-+—————-+——————–+——————–+
| 15 | 1299519817 | 1 | 0 | hjl | 0 | 15 | sunwg_test09 | EXTERNAL_TABLE | NULL | NULL |
+——–+————-+——-+——————+——-+———–+——-+—————-+—————-+——————–+——————–+
1 row in set (0.01 sec)
可以看到该表的类型为EXTERNAL_TABLE。
mysql> select * from SDS where SD_ID=15;
+——-+——————————————+—————+———————————+————-+————————————————————+———-+
| SD_ID | INPUT_FORMAT | IS_COMPRESSED | LOCATION | NUM_BUCKETS | OUTPUT_FORMAT | SERDE_ID |
+——-+——————————————+—————+———————————+————-+————————————————————+———-+
| 15 | org.apache.hadoop.mapred.TextInputFormat | | hdfs://hadoop00:9000/hjl/test08 | -1 | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | 15 |
+——-+——————————————+—————+———————————+————-+————————————————————+———-+
1 row in set (0.00 sec)
在表SDS中记录了表sunwg_test09的数据文件路径为hdfs://hadoop00:9000/hjl/test08。
实际上外表不光可以指定hdfs的目录,本地的目录也是可以的。
比如:
CREATE EXTERNAL TABLE test10(id INT, name string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘\t’
LOCATION ‘file:////home/hjl/sunwg/’;
- hive中的外表EXTERNAL TABLE
- hive中的外表EXTERNAL TABLE
- hive中的外表EXTERNAL TABLE
- hive中的外表EXTERNAL TABLE
- oracle外表(external table)
- oracle中创建外表(external table)
- 学习掌握oracle外表(external table)
- Hive Managed Table与 External Table区别
- Hive 之Table、External Table、Partition(五)
- hive external table partition 关联HDFS数据
- Hive create external table partition关联数据文件
- hive external table partition 关联HDFS数据
- hive中Table与External Table的去别
- hive 创建外表
- hive 创建外表
- hive建立外表
- hive 创建外表操作
- hive中的bucket table
- Java/JSP中使用JDBC连接SQLServer2005
- Oracle PL/SQL Profiler应用指南
- IT公司面试题
- 关键字重命名(1)
- C语言中#和##宏
- hive中的外表EXTERNAL TABLE
- 课堂感受
- c++笔试必考内容:const使用详解
- sqlplus / as sysdba ora-01031: insufficient privileges
- 彻底删除oracle
- C++中 const的用法
- 9款适合新手开发的WordPress主题
- AsyncTask
- java导出excel,以及相关实例jxl ,插入图片,指定格式文字