nbparam=$#
case $nbparam in
0) echo "Usage = sh purge_sql_plan.sh <until_date>"
exit 1;;
*);;
esac
export date=$1
sqlplus 'CONN_STRING' <<aa
set echo on timing on
DECLARE
min_date DATE;
BEGIN
SELECT MIN (timestamp) INTO min_date FROM SYS.WRH\$_SQL_PLAN;
WHILE min_date < TO_DATE ('$date', 'DD/MM/YYYY')
LOOP
DBMS_OUTPUT.put_line ('Date : ' || min_date);
DELETE FROM SYS.WRH\$_SQL_PLAN
WHERE timestamp <= min_date;
COMMIT;
min_date := min_date + 1;
END LOOP;
END;
/
ALTER TABLE SYS.WRH\$_SQL_PLAN move parallel tablespace sysaux;
ALTER TABLE SYS.WRH\$_SQL_PLAN noparallel;
alter index SYS.WRH\$_SQL_PLAN_PK rebuild parallel;
alter index SYS.WRH\$_SQL_PLAN_PK noparallel;
exit;
aa
No comments:
Post a Comment