SQL(HIVE)-insert用法

hive创建表

  • insert法
# select插入法(into 追加,overwrite重写)
insert into table tablename1 select * from tablename2
# 自定义插入法
insert into table tablename1 values ('Rsd','11');
# 对多个表进行插入操作
from tablename3
insert overwrite table tablename1 [partition (partcol1=val1,partclo2=val2)] select_statement1
insert overwrite table tablename2 [partition (partcol1=val1,partclo2=val2)] select_statement2
eg:
from tablename3
insert overwrite table tablename1
select tablename3.key
insert overwrite table tablename2
select tablename3.value;
  • create法
# like 复制表结构
create table tablename1 like tablename2;
# as  结构和值都会复制
create table tablename1 as select * from tablename2;
# 直接创建
CREATE TABLE `database.tablename1 `( 
`dept_no` int, 
`addr` string, 
`tel` string)
partitioned by(statis_date string ) 
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' 

你可能感兴趣的:(SQL,hive,sql,数据库)