-------------------------------查看表结构的相关信息---------------------------------------------
1.查看表结构
describe 数据库名称.表名;
2.查看表的具体信息
describe formatted 数据库名称.表名;
3.查看表有哪些分区
show partitions 数据库名称.表名;
4.查看建表语句
show create table 数据库名称.表名;
---------------------------------------加载数据------------------------------
1.非分区表中的数据加入分区表(未指定分区,会自动创建分区元数据信息)
insert overwrite table 数据库名称.表名 partition (dt)
select *,now(),now(),'9999-09-09' DT from 数据库名称.表名1;
2.分区表中的数据加入分区表(未指定分区)
insert overwrite 数据库名称.表名 partition (dt='2021-10-18')
select * from 数据库名称.表名1 where dt='2021-10-18';
例子1:insert overwrite table 库名.表名 partition (dt)
select 字段1,字段2,now(),now(),'2020-01-01' from 库名.表名;
3.使用load data inpath加载数据(相当于move)
alter table 数据库名称.表名 add partition (dt='2021-10-18');
load data inpath 'hdfs://servername/U_TEST/ODS/EMP/dt=2021-10-18'
into table 数据库名称.表名 partition(dt='2021-10-18');
注意:使用load加载数据时,需要先增加分区,才可以加载数据;数据路径要把分区带上,否则会出错;
-----------------------------------------删除分区数据---------------------------------
alter table 数据库名称.表名 drop partition(dt='2021-10-18');
----------------------------------------显示数据库------------------------------------------
show databases;
show databases like '*ods*';
------------------------------------------