首先通过命令将要执行的命令提取出来,再执行。如下

 
  
  1. db2 "select 'db2 grant control on table [Tablespace].'|| tabname ||' to user UserName' from syscat.tables where tabschema='SchemaName'"