大数据全系列 教程
1869个小节阅读:464.7k
目录
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
##3.4 表基础知识
xxxxxxxxxx
create [temporary] [external] table [if not exists] [db_name.]table_name
[(col_name data_type [column_constraint_specification] [comment col_comment], ... [constraint_specification])]
[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] 排序与分桶
[skewed by (col_name, col_name, ...)
on ((col_value, col_value, ...), (col_value, col_value, ...), ...)
[stored as directories]
[
[row format row_format] -- 设置各种分隔符
[stored as file_format] --hdfs上存储时的文件格式
| stored by 'storage.handler.class.name' [with serdeproperties (...)]
]
[location hdfs_path] --hdfs上的位置
[tblproperties (property_name=property_value, ...)] --表的属性
[as select_statement]; -- 查询子句
row_format
: delimited [fields terminated by char [escaped by char]] [collection items terminated by char]
[map keys terminated by char] [lines terminated by char]
[null defined as char]
| serde serde_name [with serdeproperties (property_name=property_value, property_name=property_value, ...)]
file_format:
: sequencefile
| textfile
| rcfile
| orc
| parquet
| avro
| jsonfile
| inputformat input_format_classname outputformat output_format_classname
column_constraint_specification:
: [ primary key|unique|not null|default [default_value]|check [check_expression] enable|disable novalidate rely/norely ]
default_value:
: [ literal|current_user()|current_date()|current_timestamp()|null ]
constraint_specification:
: [, primary key (col_name, ...) disable novalidate rely/norely ]
[, primary key (col_name, ...) disable novalidate rely/norely ]
[, constraint constraint_name foreign key (col_name, ...) references table_name(col_name, ...) disable novalidate
[, constraint constraint_name unique (col_name, ...) disable novalidate rely/norely ]
[, constraint constraint_name check [check_expression] enable|disable novalidate rely/norely ]