有时候在前台界面需要批量处理一些数据时,经常要用到update table set fields=value where keyid in ('1','2',....)
但如果这个数据量如果超过1000,在oracle里是不被支持的,这样就只能写程序循环,或者用代码以1000为单位进行or连接,效率非常低下。
一个朋友给我介绍了另一种方法,用临时表,一直没有时间测试性能,只做个记录吧
CREATE TABLE #tmp
(
taskId NVARCHAR(16) PRIMARY KEY
);
INSERT INTO #tmp SELECT '201309011659' UNION ALL SELECT '201309011667' UNION ALL SELECT '201309011656' UNION ALL SELECT '201309011515' UNION ALL SELECT '201309011560' UNION ALL SELECT '201309011462' UNION ALL SELECT '201309011520' UNION ALL SELECT '201309011275' UNION ALL SELECT '201309011440' UNION ALL SELECT '201107000096' UNION ALL SELECT '201107000840' UNION ALL SELECT '201110017158' UNION ALL SELECT '201111011453' UNION ALL SELECT '201308025857';
select taskId from #tmp;