在我的脚本中,我必须对连接表执行大量选择,因此我决定将此连接放入临时表中。删除DB2表(如果存在的话)
首先我想:
1. Create table
2. Put the data from the join into a table
3. Drop the table
但转念一想,如果什么之前,我删除的表脚本失败?
所以我决定去:
1. Drop the table
2. Create the table
3. Put the data from the join into a table
我如果表离开了那里我下次运行脚本,直到不介意,所以第二个选项也可以。
但是如果有人已经丢掉了桌子呢?
我看到一些系统有“drop if exists”,但不幸的是不是DB2。我想做一些不会让脚本在drop table失败时死掉的东西。
想法?在这一切?谢谢!
编辑:我忘了说这是在PERL脚本!
您可以使用['$ dbh-> tables'](http://search.cpan.org/~hoymich/DBD-DB2-0.78-5.8.4/lib/DBD)检查给定表的存在/DB2.pod#Getting_Table_information) – Borodin 2015-03-13 13:48:20