dbsql scripts

You can use scripts to bundle all your queries into a single file, which you can then run automatically and repeatedly. You can create a script by using any standard editor and typing regular SQL commands.

There are three ways to run scripts. The following examples apply to the Db2® managed service and to Db2 Warehouse if you did not obtain the Db2 support tools (which include the dbsql command) from the Db2 Warehouse image or client container. If you obtained the Db2 support tools from the Db2 Warehouse image or client container, see Db2 support tools overview for information about how to run the examples.
  • You can use the redirect command on the command line to specify that the system use a file instead of stdin:
       dbsql < script_file
  • You can use the dbsql command-line argument -f, which you can use to specify a file:
       dbsql -f script_file
  • You can specify the script from within the dbsql command interpreter:
       BLUDB.USER(USER)=> \i script_file