一、创建表
-
基本创建形式,没有指定分隔字符的形式,默认采用\001在文本编辑器中显示SOH,在vim中显示为^A
create table test_tb( id int )
-
指定分隔符创建,row format delimited指定使用hive自带的方法类进行分隔,fields terminated by ‘,‘指定分隔方式为字段方式,符号是’,’
create table test_tb_f( id int, name string, age int, gender string )row format delimited fields terminated by ',';
二、查看数据表
-
详情信息查看
desc extended test_tb_f;
-
详情信息格式化查看
desc formatted test_tb_f;
-
查看字段信息
desc test_tb_f;
-
查看建表语句
show create table test_tb_f;
三、删除数据表
-
删除整个表(删除整张表,包括元数据信息)
drop table python.test_tb;
-
删除表数据(删除表数据,不删除元数据)
truncate table test_tb_f;
四、修改数据表
-
修改表属性
alter table test_tb_f set tblproperties('name'='EuropeanSheik');
-
修改表名
alter table test_tb_f rename to test_tb;
-
修改表字段属性
alter table test_tb change id id string;
-
修改字段名
alter table test_tb change name username string;
-
添加新字段
alter table test_tb add columns(address string);
-
修改表的存储路径
alter table test_tb set location '/ming';