[SQL ] create table后资料遗失请益

楼主: smile0803 (鸡排)   2020-03-22 00:48:27
数据库名称: Teradata SQL
数据库版本:15
内容/问题描述:
各位大神好~
小妹是数据分析的菜鸟,昨天create了ㄧ张大表后,发现原始的资料笔数应为27万,但cr
eate后的table资料笔数却少了2万笔....
因为这大表join了很多table,字段也建了不少,所以只能简单把逻辑打出来,希望有大
神能协助解惑怎么create table会造成资料遗失QQ. 谢谢!!
#建立test
Create table DB.test as
(
Select a.ID , b.ID , c.ID
From ( select ID from table1
union
select name as ID from table2) as a
Left join table3 b on a.ID =b.ID
Left join table4 c on a.ID =c.ID
) with data;
#此资料笔数为27万
Select count(*)
From (
Select a.ID , b.ID , c.ID
From ( select ID from table1
union
select name as ID from table2) as a
Left join table3 b on a.ID =b.ID
Left join table4 c on a.ID =c.ID
) t
#建立的资料笔数变为25万
Select count(*) from DB.test
※ 编辑: smile0803 (219.91.86.65 台湾), 03/22/2020 00:52:24
作者: criky (2501-2)   2020-03-22 05:56:00
可能是Union指令,改成Union all试试看?create table时加mutiset也可以试试看
作者: hmsDEBBIE (*黛比*)   2020-03-22 23:43:00
推楼上,请试试create multiset table以及改成union all
作者: joery (Lin)   2020-03-25 18:12:00
楼上二位大大超强

Links booklink

Contact Us: admin [ a t ] ucptt.com