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)
-
--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)
-
--sslFile
| --ssl
(string)
- Path to an SSL Certificate file
Profile Options
Base Connection Options
-
--reject-unauthorized
| --ru
(boolean)
-
--token-type
| --tt
(string)
- The type of token to get and use for the API. Omit this option to use the default token type, which is provided by 'zowe auth login'.
-
--token-value
| --tv
(string)
- The value of the token to pass to the API.
-
--cert-file
(local file path)
- The file path to a certificate file to use for authentication
-
--cert-key-file
(local file path)
- The file path to a certificate key file to use for authentication
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