我有一个 500,000 行的 sql 脚本。
update users set region_id = 9814746 where id = 101 and region_id is null;
update users set region_id = 9814731 where id = 102 and region_id is null;
update users set region_id = 3470676 where id = 103 and region_id is null;
...
....
我需要能够使用 begin...commit 每 50 行生成一个脚本。 我该怎么做呢? 我将在 pg-admin 中运行它。
谢谢, 沙拉多夫
最佳答案
这可能是一个好的开始:
cat sql.file | perl -e 'i=0;print "begin;\n"; while(<>){print;i++;if(i % 50 == 0){print "end;\nbegin;\n";}}print "end\n";' > outputsql.file
关于postgresql - 开始...每 50 行提交一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1307735/