-1

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.

jarlh
  • 42,561
  • 8
  • 45
  • 63
Vivek Rana
  • 43
  • 1
  • 4

1 Answers1

0

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
ScottMcG
  • 3,867
  • 2
  • 12
  • 21
  • Hi I have created one script and inside the script I use below nzsql nzsql -d {Database} -q -c"delete from table where clause" -o output_file.out I am putting the output of the delete statement in the output_file.out but the delete command is not returning any count of how many rows are deleted. Is there any way I can do that/ – Vivek Rana Sep 10 '15 at 03:52
  • 1
    You specified the `-q` option, which [removes all non-query output](https://www-304.ibm.com/support/knowledgecenter/SSULQD_7.1.0/com.ibm.nz.dbu.doc/r_dbuser_command_line_options.html). Remove the q. – Jeremy Fortune Sep 10 '15 at 10:22