当前位置: 首页> 科技> IT业 > hive学习(二)

hive学习(二)

时间:2025/7/11 23:33:34来源:https://blog.csdn.net/2301_79721847/article/details/141110902 浏览次数:0次

一、表的DDL操作

1、建表语法

CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name 
[(col_name data_type [COMMENT col_comment], ...)] 
[COMMENT table_comment] 
[PARTITIONED BY (col_name data_type [COMMENT col_comment], ...)] 分区
[CLUSTERED BY (col_name, col_name, ...) 分桶
[SORTED BY (col_name [ASC|DESC], ...)] INTO num_buckets BUCKETS] 
[ROW FORMAT row_format]   row format delimited fields terminated by “分隔符”
[collection items terminated by ':'] (指定struct数据类型内的分隔符)
[map keys terminated by ':'] (指定map键值对的分隔符)
[STORED AS file_format] 
[LOCATION hdfs_path]

以下是语法的解释

2. 创建内部表

1)直接建表

create table if not exists teacher(
id int, 
name string
)
row format delimited fields terminated by '\t'	
stored as textfile;//默认是文本文件

2)查询建表法

//从已有表中获取信息建表
create table if not exists teacher1 as select id, name from teacher;

3)like建表法

create table if not exists teacher2 like teacher;

扩:查询表类型

hive > desc formatted teacher;

关键字:hive学习(二)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: