How would I execute a sql script on a remote db2 server?
In MySQL I would have done something like this:
mysql -uroot -proot -h localhost < resources/db_scripts/drop_mysql.sql >> logs/drop_my.log
I would also like to do the same for MSSQL and Sybase.
You can do that type of operation in DB2 with the “Data Server client” (it had other names in previous DB2 versions, for example “DB2 Administration client”). This application has a set of tools that permit you to control a local or remote database. The most appropriated tool for your case is called the “Command Window”.
In order to start working with remote database via the Command Window, you have to “see” the remote databases, and for this, you catalog a remote machine (catalog admin node), a remote instance (catalog node) and then the database (catalog database). It looks complicated, and to prevent this problem, there is a graphical tool called the DB2 Configure assistant (db2ca) that permits you to configure the DB2 environment.
Once you have catalog your remote database, you can do
As part of your script file, you should have the connection statement (db2 connect to ALIAS user USERNAME using PASSWORD) or you have to establish the connection before call the execution of the script file.