I'm brand new to DB2 as I've always used SQL Server. My company has just released a DB2 SQL script to the client that they're having trouble running due to performance issues. The script keeps running for 2+ hours before they cancel it.
The issue appears to be on a update with a subquery running against a temp table while the live table is dropped and recreated with different columns. The guy who wrote it is unavailable to help but suggested that I change the script to export the information to an external file instead of a temp table before changing the live table and importing back in again.
How do you do this? I have no idea how to export data to a csv or txt file from SQL. Any tips or pointers would be greatly appreciated.
I'm using DB2 v188.8.131.52 on Windows 2000 server if it makes a diffference.
You can always check the syntax:
db2 ? export
but if you like a simple example, here it is:
db2 export to MyFile.ixf of ixf select * from MyTable
db2 export to MyOtherFile.del of del select * from MyOtherTable
The extension is not mandatory; it serves as a reminder of what you have done.