hive创表语句

Hive的建表\插入语句

创建规则:

CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name    -- (Note: TEMPORARY available in Hive 0.14.0 and later)
		  [(col_name data_type [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, ...)                  -- (Note: Available in Hive 0.10.0 and later)]
			 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 (...)]  -- (Note: Available in Hive 0.6.0 and later)
		  ]
		  [LOCATION hdfs_path]
		  [TBLPROPERTIES (property_name=property_value, ...)]

插入规则:

INSERT INTO|OVERWRITE TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1

创建普通表:

create table if not exists jz_tmp.test_studentinfo (id int,name string,gender string, age int)

插入普通表:

insert into jz_tmp.test_studentinfo values(1,'hxh','A',20)

创建分区表:

create table if not exists jz_tmp.test_student_01(
	id int
	,name string
	,gender string
	,age int) 
partitioned by (f_p_date string comment '') stored as orc 

插入分区表:

insert into jz_tmp.test_student_01 partition (f_p_date='2020-03-16') values(1,'hxh','S',18)`

你可能感兴趣的:(Hive,SQL)