我有一个简单的插入语句,该语句在DEV_1数据库上可以正常工作,但是在DEV_2数据库上执行时会挂起。
select语句返回200行,并需要7秒钟来执行。 已经检查了锁。
INSERT INTO test_table
SELECT account
FROM table_1 a,
table_2 q,
table_3 c
WHERE a.bkg_date = q.prev_working_day
AND a.branch_code = q.branch_code
AND a.account = c.ref_no
AND a.account NOT IN (SELECT DISTINCT x.account
FROM table_1 x,
(SELECT a.account,
MAX(a.bkg_date) bkg_date
FROM table_1 a,
table_4 b
WHERE a.lcy_closing_bal < 0
AND a.account = b.cust_ac_no
GROUP BY a.account) y
WHERE x.account = y.account
AND x.bkg_date > y.bkg_date
AND x.lcy_closing_bal >= 0 HAVING COUNT(x.account) > 1
GROUP BY x.account);
我也尝试过使用create table作为select ..效果很好。我想了解创建表的工作原理,但插入件已挂起。
Create table abc as
( select ...)