BEGIN FOR c IN (SELECT OBJECT_NAME FROM dba_objects WHERE owner!='SYS' AND object_type = 'SYNONYM' AND status='INVALID') LOOP BEGIN EXECUTE IMMEDIATE 'drop public synonym ' || c.object_name; END; END LOOP; END; /