Netezza- getting count of deleted records from a SQL statement

960 Views Asked by At

I am creating a script in Unix where I can put multiple delete NZSQL one after the other.

But since the data volume is huge in each table, I want the script to display the output of each delete SQL, like how many records were deleted and how much time was taken for each delete SQL.

The output of each SQL can be put in a file that we can refer to see the progress and get the detail up to which step the SQL are executed.

This is to be done in Netezza.

1

There are 1 best solutions below

2
ScottMcG On

The output of the DELETE command specifies the number of rows that were deleted, so you are already provided with that information. You can invoke nzsql with the "-time" option or specify "\time" in the script, and the execution time for each step will also be printed.

All the information needed by your script is there in the output.

TESTDB.ADMIN(ADMIN)=> \time
Query time printout on
TESTDB.ADMIN(ADMIN)=> select count(1) from test_table;
 COUNT
-------
     7
(1 row)

Elapsed time: 0m0.216s
TESTDB.ADMIN(ADMIN)=> delete from test_table;
DELETE 7
Elapsed time: 0m1.532s