dbsql command inputs
You can input SQL commands to the dbsql interpreter by using a variety of command options.
Using the dbsql command, you can specify different input options. The
following examples apply to the Db2® managed service and to IBM® 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 the
Db2 support tools
overview for information about how to run the examples. Also, if you obtained the Db2 support tools from the Db2 Warehouse image container, see dbsql command for information about rules for escaping
quotation marks.
-
To run a single query from the dbsql command line, enter:
dbsql -c "SELECT * FROM test_table"
- On UNIX clients, to read input from the current source, for example a script, enter:
dbsql <<eof SELECT * FROM test_table; eof
- To read a file of commands from standard input,
enter:
dbsql < foo.sql
- To run queries from a file (command-line argument), enter:
dbsql -f foo.sql
- To run queries from a file after you have logged in to the dbsql command
interpreter, use the \i command:
BLUDB.JOHN(JOHN)=> \i foo.sql