zowe › db2 › execute › sql
Execute one or multiple SQL statements separated by a semicolon from a command line or from a file.
Usage
zowe db2 execute sql [options]
Options
--query|-q(string)- The SQL statement verbatim to execute
--file|-f(string)- A local file containing the SQL statements to execute
DB2 Connection Options
--host|-H(string)- The Db2 server host name
--port|-P(number)- The Db2 server port number
--user|-u(string)- The Db2 user ID (may be the same as the TSO login)
--password|--pass|--pw(string)- The Db2 password (may be the same as the TSO password)
--database|--db(string)- The name of the database
--sslFile|--ssl(string)- Path to an SSL Certificate file
Profile Options
--db2-profile|--db2-p(string)- The name of a (db2) profile to load for this command execution.
Examples
Execute a dummy SQL query:
zowe db2 execute sql --query"SELECT 'Hello World' FROM SYSIBM.SYSDUMMY1"
Retrieve the employees table and total number of rows:
zowe db2 execute sql -q "SELECT * FROM SAMPLE.EMP; SELECT COUNT(*) AS TOTAL FROM SAMPLE.EMP"
Execute a file with SQL statements:
zowe db2 execute sql --file backup_sample_database.sql