获取错误:ORA-00905:尝试从子查询中插入临时表中的行时缺少关键字错误

时间:2016-04-07 03:32:36

标签: sql oracle

select customernumber into total 
from (select customernumber 
      from ccsowner.customer 
      where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS))

通过。

创建的临时表
Create Table Total
(
    customernumber   Int
)

1 个答案:

答案 0 :(得分:1)

Select Into仅在表不存在时才有效。您可以使用以下SQL将数据插入现有表。

试试这个 -

Insert into Total 
 select customernumber 
    from ccsowner.customer 
    where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS)

如果要使用SELECT INTO,可以使用以下SQL(它将动态创建Total表,如果Total表已经存在则会出错):

;with cte_Cust As (
    Select customernumber 
      from ccsowner.customer 
      where customernumber not in (select customernumber from MOBILEACCOUNTDETAILS))


Select customernumber Into Total
   From cte_Cust