sqlplus 变量定义:
COLUMN spool_time NEW_VALUE _spool_time NOPRINT
SELECT TO_CHAR(SYSDATE,'YYYYMMDDhh24miss') spool_time FROM dual;
查看和引用变量:
define _spool_time
&_spool_time
select a.snap_id, to_char(a.END_INTERVAL_TIME,'yyyy-mm-dd hh24:mi:ss') snap_time from dba_hist_snapshot a
where a.instance_number=(select b.instance_number from v$instance b)
and a.END_INTERVAL_TIME > sysdate-&days
order by 1;
COLUMN MIN_SNAP NEW_VALUE bid NOPRINT
COLUMN MAX_SNAP NEW_VALUE eid NOPRINT
--TRIM 删除空格.
SELECT TRIM(MAX_SNAP) MAX_SNAP,TRIM(MIN_SNAP) MIN_SNAP FROM
(
select MAX(a.snap_id) MAX_SNAP,MIN(a.snap_id) MIN_SNAP from dba_hist_snapshot a
where a.instance_number=(select b.instance_number from v$instance b)
and a.END_INTERVAL_TIME > sysdate-7);
define bid
define eid