建表:
create table if not exists xx;
创建临时视图:
create or replace temporary view table_name as
hive表重命名(无法修改成已建过的表):
alter table table_name rename to new_table_name;
删表:
drop table if exists xx;
删除一列:
alter table xx drop 列名;
清空表:
truncate table xx
添加表字段:
alter table xx add columns (member string comment '会员');
修改表字段顺序:
alter table xx change 字段名(需要修改的字段) 字段名 需要修改的字段)字段类型 after 字段名(具体在哪个字段之后)
alter table xx A A string after B;
修改字段备注:
alter table xx change column id id string comment 'ccid前三位';
删除分区:
alter table xx drop partition (time='xx',date='xx',channel=' xx');
导入数据:
load data local inpath '/xx/xx.csv' overwrite into table xx;
插入数据:
insert overwrite xx partition (time,date,channel)
insert into xx partition (time,date,channel)
创建视图:
create or replace temporary view 视图名 as select ...
create or replace temporary view 视图名(
字段名 字段类型,
AA string...)
USING org.apache.spark.sql.execution.datasources.csv.CSVFileFormat
OPTIONS(
PATH 'XX/XX',
header 'true',
delimiter '\001',
quote '"'
);
持续更新中。。。