You can use pgISQL in the command line mode.

For example, you can:

  • Create Windows Task Scheduler job running pgISQL (or .BAT file);
  • Create SQL script for some routine DB administrative task and save it in a file;
  • Set pgISQL command line in Windows Task Scheduler job (or in .BAT file mentioned above) with this SQL script file name, and activate this job.
Example: (all paths was shortened):

Sample .BAT file

c:\PgISQL.exe -ddbdemos -hlocalhost -p5432 -uvic -c -s"c:\COPY_COMMAND.sql" -l"c:\run.log"
GOTO E%ERRORLEVEL%
:E0
   echo Return Code 0 > PgISQLReturnCode.txt
   exit /B
:E1
   echo Return Code 1 > PgISQLReturnCode.txt  
   exit /B


COPY_COMMAND.sql

COPY "country"  WITH OIDS TO 'country.txt'  USING DELIMITERS ',' WITH NULL AS 'NULL';
COPY "customer" WITH OIDS TO 'customer.txt' USING DELIMITERS ',' WITH NULL AS 'NULL';
COPY "employee" WITH OIDS TO 'employee.txt' USING DELIMITERS ',' WITH NULL AS 'NULL';
COPY "orders"   WITH OIDS TO 'orders.txt'   USING DELIMITERS ',' WITH NULL AS 'NULL';

pgISQL command line parameters:

KeyFunctionExampleComment
-D[-d]<dbname>DataBase name-DdbdemosRequired.
-H[-h]<dbhost>Host name or IP-HlocalhostRequired.
-U[-u]<dbuser>User name-UpostgresRequired.
-P[-p]<dbport>Server port-P54325432 by default.
-W[-w]<dbpasswd>User's password-WsqlIs not required if password is empty.
-W (empty key) is allowed too.
-C[-c]Close pgISQL after SQL script executing-CAfter SQL script will be executed successfully pgISQL ruturns exit code "0". Otherwise pgISQL ruturns exit code "1".
If you launch pgISQL from .BAT (.CMD) file, check ERRORLEVEL to make a choice which way you should go.
-S[-s]<"file path">Path to SQL script file-S"c:\sql\sqlscript.sql"Is not required.
Hint: make a shortcut, set DataBase parameters, and place it on QuickLaunch.
-L[-l]<"file path">Log SQL script executing results into file-L"c:\Program Files\PgISQL\cmdlog.log"Is not required.