标签:
HQL语法基于 SqlLine(http://sqlline.sourceforge.net/),DDL主要包含数据库、函数、视图的创建、修改、删除,参考资料:(https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL), 语法关键字:
DataBase:
CREATE (DATABASE|SCHEMA) [IF NOT EXISTS] database_name
[COMMENT database_comment]
[LOCATION hdfs_path]
[WITH DBPROPERTIES (property_name=property_value, ...)];
drop 语法:
DROP (DATABASE|SCHEMA) [IF EXISTS] database_name [RESTRICT|CASCADE];
DataTable:
CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name
[(col_name data_type [COMMENT col_comment], ...)]
[PARTITIONED BY (col_name data_type [COMMENT col_comment], ...)]
[CLUSTERED BY (col_name, col_name, ...) [SORTED BY (col_name [ASC|DESC], ...)]
[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]
| STORED BY ‘storage.handler.class.name‘ [WITH SERDEPROPERTIES (...)]
]
[LOCATION hdfs_path]
[TBLPROPERTIES (property_name=property_value, ...)]
[AS select_statement];
CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name
LIKE existing_table_or_view_name
create table if not exists students(
ID string,
Code string,
Name string,
Score decimal(20,8),
address struct<street:string,city:string,state:string,zip:string>
) tblProperties(‘creator‘=‘tgzhu‘,‘version‘=‘1.0‘);
create table if not exists student1 like students;
分区表:
create table student_p( id string, name string, age int, birthday date ) partitioned by(region string, sex string);
桶表:
create table student_c( id string, name string, age int, birthday date ) partitioned by(region string, sex string) clustered by(id) sorted by(birthday) into 64 buckets;
标签:
原文地址:http://www.cnblogs.com/tgzhu/p/5767230.html