前言

本文主要介绍hive中对表的改动基本内容

一、修改表

hive的使用中经常会有修改表的操作,本文简单的介绍hive表的修改

二、具体操作

1.重命名表

create table table_a(id int); //创建表table_a;
alter table table_a rename to table_b;//重命名table_a为table_b

2.更新修改列

alter table table_a change column id student_id int;//将列名id修改为student_id,类型不变
alter table table_a change column student_id student_id string;//不修改列名,仅修改列的类型为string
desc table_a;//查询表的结构信息
alter table table_a add columns(name string)//向table_a表中新增一列,列名为name,类型为string
alter table table_a change name name string first;//调整列name在最前面
alter table table_a change name name string after student_id;//将name更新到指定列的后面
alter table table_a replace columns(age int);//替换所有的列
drop table table_a;//删除表

本文总结的是hive中对表的基本操作,分区表跟桶下期再进行总结