SQL Plan to check history about a plan


set linesize 1000
select
  sql.plan_hash_value      plan,
  to_char(s.begin_interval_time,'dd/mm/yyyy hh24:mi')  begin,
  sql.sql_id               id,    
  sql.executions_delta     ,
  sql.OPTIMIZER_COST       ,
  sql.SORTS_DELTA          ,
  sql.DISK_READS_DELTA     ,
  sql.BUFFER_GETS_DELTA    ,
  sql.ROWS_PROCESSED_DELTA ,
  sql.CPU_TIME_DELTA       ,
  sql.ELAPSED_TIME_DELTA
from
   dba_hist_sqlstat        sql,
   dba_hist_snapshot         s
where
   s.snap_id = sql.snap_id
   and sql_id='&sqlid'
order by 1,2
;
Enter value for sqlid: 7pwn4bv77m7vp
old  18:    and sql_id='&sqlid'
new  18:    and sql_id='7pwn4bv77m7vp'

or 


SELECT plan_table_output FROM table(DBMS_XPLAN.display_cursor ('&V_SQL_ID',NULL,'ALL' )); 

SQL> select * from table(dbms_xplan.display_awr('&sql_id'));
Enter value for sql_id: 7pwn4bv77m7vp
old   1: select * from table(dbms_xplan.display_awr('&sql_id'))
new   1: select * from table(dbms_xplan.display_awr('7pwn4bv77m7vp'))