安溪城乡建设局网站,买链接,深圳网站快速优化公司,做视频网站需要多大的带宽目录 一、背景
二、准备测试数据
1.建表
2.造测试数据
三、操作
1.CTAS
#xff08;1#xff09;.无分区表测试
#xff08;2#xff09;.分区表测试
2.LIKE
#xff08;1#xff09;.无分区表测试
#xff08;2#xff09;.分区表测试 一、背景
有一张ori_…目录 一、背景
二、准备测试数据
1.建表
2.造测试数据
三、操作
1.CTAS
1.无分区表测试
2.分区表测试
2.LIKE
1.无分区表测试
2.分区表测试 一、背景
有一张ori_table,想新建一张表new_table,保持跟ori_table一样的表结构但是不复制ori_table的数据。 二、准备测试数据
1.建表
create table ori_table (
id bigint,
col1 string,
col2 double
)comment 无分区原始表
stored as orc;create table ori_table_partition (
id bigint,
col1 string,
col2 double
)comment 有分区原始表
partitioned by (dt string)
stored as orc; 2.造测试数据
insert into ori_table values (1,哈哈,10.02);
insert into ori_table values (2,嘿嘿,20.06);
insert into ori_table values (3,嘻嘻,30.08);insert into ori_table_partition partition(dt1) values (1,哈哈,10.02);
insert into ori_table_partition partition(dt2) values (2,嘿嘿,20.06);
insert into ori_table_partition partition(dt3) values (3,嘻嘻,30.08); 三、操作
有2种办法
1.CTAS
1.无分区表测试
--复制与ori_table表结构及表数据都一致的语句create table new_table as select * from ori_table;--只复制与ori_table表结构的语句
create table new_table as select * from ori_table where 10;
show create table new_table; --执行看一下效果 select * from new_table; --执行看一下数据量 由此得出结论无分区表使用该语句可以满足需求 2.分区表测试
--复制与ori_table_partition表结构及表数据都一致的语句create table new_table_partition as select * from ori_table_partition;--只复制与ori_table表结构的语句
create table new_table_partition as select * from ori_table_partition where 10; show create table new_table_partition; --执行看一下效果 这里看到表结构还是有些差异的执行后将分区表建成了无分区表分区字段创建成了普通字段。 select * from new_table_partition; --执行看一下数据量 结论
CTAS语法不适用于分区表 2.LIKE
1.无分区表测试
--只复制与ori_table表结构的语句
create table new_table_like like ori_table;
show create table new_table_like; --执行看一下效果 select * from new_table_like; --执行看一下数据量 2.分区表测试
--只复制与ori_table_partition表结构的语句
create table new_table_partition_like like ori_table_partition;
show create table new_table_partition_like; --执行看一下效果 select * from new_table_partition_like; --执行看一下数据量 结论
LIKE语法适用于分区表及无分区表