1.先根据一定规则获取要查询的SQL
select 'select distinct USER_ACCOUNT as USER_ACCOUNT from '||OWNER||'.'||TABLE_NAME||' where PARTITION_ID>=23 and PARTITION_ID<=29 union all' from dba_tables where TABLE_NAME like 'T_UR%_USER' and OWNER like 'TEST_DB%';
2.根据步骤1中获取的SQL编写简单的Shell脚本
sqlplus username/passwd as sysdba >/dev/null 2>&1 <<EOFset time off echo off head offset feedback offset heading offset pagesize 0set termout offset trimout offset trimspool offspool user.accounts.dat--步骤1中获取的SQLspool offEOF