dbsql command feedback
When you issue SQL commands from dbsql, you either succeed or receive an error. In either case, the system provides feedback that you can use in a script.
The command feedback for inserts, updates, and deletes shows you the number of rows that are
acted upon. The feedback for inserts includes an extra zero before the actual number (because of a
historical artifact). Sample commands (shown in bold) and the command feedback follows. 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.
dbsql -d bludb -u admin1 -pw mypassword
CREATE TABLE test1 (col1 INTEGER, col2 INTEGER, col3 CHARACTER(40));
CREATE TABLE
INSERT INTO test1 VALUES (100, 200, 'This is a test');
INSERT 0 1
INSERT INTO test1 VALUES (101, 201, 'Another test');
INSERT 0 1
UPDATE test1 SET col2 = 999 WHERE col1 < 1000;
UPDATE 2
INSERT INTO test1 SELECT * FROM test1;
INSERT 0 2
delete from test1 where col1 >0
DELETE 4
TRUNCATE TABLE test1 IMMEDIATE;
TRUNCATE TABLE
DROP TABLE test1;
DROP TABLE
You can also pass the SQL operation as a part of the dbsql command using
double quotes:
dbsql -d bludb -u admin1 -pw mypassword "CREATE TABLE test1 (col1 INTEGER, col2 INTEGER, col3 CHARACTER(40))"