hive表的DDL操作

来源:互联网 发布:知巳手机 编辑:程序博客网 时间:2024/05/17 03:40
查看表
hive> show tables;

创建表
hive> create table t1(id int);

查看表结构
hive> desc [extended] t1;
extended是可选的,是扩展的表的信息

删除表
hive> drop table t1;

重命名表的名称
hive> alter table t1 rename to t1_ddl;

修改表中的某一列
hive> alter table t1_ddl change id t_id int;

增加列
mysql:alter table add column colname coltype;
hive> alter table add columns (colname coltype...);可以增加多列
hive> alter table t1_ddl add columns(name string comment 'name', age int); 

替换整个表列
hive> alter table t1_ddl replace columns(name string comment 'name', age int);

移动某一列的位置
将某一列放在最前面
hive> alter table t1_ddl add columns(id int);(增加原有的数据)
hive> alter table t1_ddl change id id int first;

将某一列移动到另外一列的后面或前面
hive> alter table t1_ddl change age age int after id;(将age放在id的后面或name的前面)
但是没有提供before和last的实现
0 0
原创粉丝点击