Tuesday, July 30, 2013

How to execute sql script file in db2 command prompt

db2 -tvsf <script>.sql

2 comments:

  1. To run with a specific db user:

    $ db2 connect to unicadb user uc using passw0rd

    Database Connection Information

    Database server = DB2/LINUXX8664 10.1.3
    SQL authorization ID = UC
    Local database alias = UNICADB


    $ db2 -vf aci_systab_db2.sql -t

    ReplyDelete
  2. Note: if it has stored procedures, you need to run it as :
    b2 +c -td@ -vf aci_populate_runtab_db2.sql

    Or else you will get errors like:
    DB21034E The command was processed as an SQL statement because it was not a
    valid Command Line Processor command. During SQL processing it returned:
    SQL0104N An unexpected token "into" was found following "_RTDepStatus@
    insert". Expected tokens may include: "LIMIT". SQLSTATE=42601

    ReplyDelete