how to remove "Elapsed" in sqlplus
vi $ORACLE_HOME/sqlplus/admin/glogin.sql to remove "Elapsed"
最近在寫shell指令碼的時候,發現了一個問題,之前沒有注意過的問題,而這個問題又是恰恰導致我們帶庫不正常的原因。
1. 重現Elapsed: 00:00:00.05標識
SQL> conn ecc_view/ecc@devdb
Connected.
SQL> set heading off
SQL> set feedback off
SQL> select table_name from user_tables;
ECC_VIEW1
TEST
SM_OPER_LOG_BAK
SM_OPER_LOG
TABLE1
T
T3
Elapsed: 00:00:00.19
每次執行完sql語句的時候,最後一行總是帶有一個Elapsed: 00:00:00.19時間統計資訊,這個欄位會影響我後續的shell指令碼的執行。
比如說spool一個parfile,我只能在cat 出一個去掉Elapsed的指令碼出來
e.g. cat /u01/oracle/parfile1.sql |grep -v Elapsed > /u01/oracle/parfile2.sql
2. 去掉sql語句執行後的時間統計資訊
vi $ORACLE_HOME/sqlplus/admin/glogin.sql
[oracle@rac1 admin]$ more glogin.sql
--
-- Copyright (c) 1988, 2004, Oracle Corporation. All Rights Reserved.
--
-- NAME
-- glogin.sql
--
-- DESCRIPTION
-- SQL*Plus global login "site profile" file
--
-- Add any SQL*Plus commands here that are to be executed when a
-- user starts SQL*Plus, or uses the SQL*Plus CONNECT command
--
-- USAGE
-- This script. is automatically run
-- Used by Trusted Oracle
COLUMN ROWLABEL FORMAT A15
-- Used for the SHOW ERRORS command
COLUMN LINE/COL FORMAT A8
COLUMN ERROR FORMAT A65 WORD_WRAPPED
-- Used for the SHOW SGA command
COLUMN name_col_plus_show_sga FORMAT a24
COLUMN units_col_plus_show_sga FORMAT a15
-- Defaults for SHOW PARAMETERS
COLUMN name_col_plus_show_param FORMAT a36 HEADING NAME
COLUMN value_col_plus_show_param FORMAT a30 HEADING VALUE
-- Defaults for SHOW RECYCLEBIN
COLUMN origname_plus_show_recyc FORMAT a16 HEADING 'ORIGINAL NAME'
COLUMN objectname_plus_show_recyc FORMAT a30 HEADING 'RECYCLEBIN NAME'
COLUMN objtype_plus_show_recyc FORMAT a12 HEADING 'OBJECT TYPE'
COLUMN droptime_plus_show_recyc FORMAT a19 HEADING 'DROP TIME'
-- Defaults for SET AUTOTRACE EXPLAIN report
-- These column definitions are only used when SQL*Plus
-- is connected to Oracle 9.2 or earlier.
COLUMN id_plus_exp FORMAT 990 HEADING i
COLUMN parent_id_plus_exp FORMAT 990 HEADING p
COLUMN plan_plus_exp FORMAT a60
COLUMN object_node_plus_exp FORMAT a8
COLUMN other_tag_plus_exp FORMAT a29
COLUMN other_plus_exp FORMAT a44
-- Default for XQUERY
COLUMN result_plus_xquery HEADING 'Result Sequence'
-- User Vi
define_editor=vi
--set timing on
set timing off
set serveroutput on size 100000
set linesize 120
set pagesize 999
set trimspool on
set long 5000
set termout on
[oracle@rac1 admin]$
3. 再次執行select語句
[oracle@rac1 ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Aug 3 12:42:46 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
SQL> conn ecc_view/ecc@devdb
Connected.
SQL> set heading off
SQL> set feedback off
SQL> select table_name from user_tables;
ECC_VIEW1
TEST
SM_OPER_LOG_BAK
SM_OPER_LOG
TABLE1
T
T3
說明:vi $ORACLE_HOME/sqlplus/admin/glogin.sql以後,註釋set timing on ,執行時間提示符 Elapsed: 00:00:00.19就沒有了。
相關命令解析如下:
--定義緩衝編輯器為vi
define_editor=vi
--使DBMS_OUTPUT有效,並設定成最大buffer,並防止"吃掉"最前面的空格
set serveroutput on size 1000000 format wrapped
--設定一行可以容納的字元數
set linesize 256
--設定一頁有多少行數
set pagesize 50
--設定來回資料顯示量,這個值會影響autotrace時一致性讀等資料
set arraysize 5000
--頁和頁之間不設任何間隔
set newpage none
--LONG或CLOB顯示的長度
set long 5000
--將SPOOL輸出中每行後面多餘的空格去掉
set trimspool on
--設定查詢耗時
set timing on
--autotrace後explain plan output的格式
col plan_plus_exp format a120
--在螢幕上暫不顯示輸出的內容,為下面的設定sql做準備
set termout off
e.g. 7 rows selected.
--設定時間格式
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
--獲得使用者名稱和global_name
col login_info_temp new_value login_info
select login_info_temp from global_name;
--設定sql提示為""
set sqlprompt '&login_info SQL> '
--在螢幕上顯示輸出的內容
set termout on
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9252210/viewspace-611123/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- how to remove datafile pathREM
- WINNT: How to Remove Oracle Fail Safe From a Windows NT Cluster ServerREMOracleAIWindowsServer
- 轉載 個人用 How To Remove Docker Images, Containers, and VolumesREMDockerAI
- How to Create or Remove Restore Point on Standby database (文件 ID 1672977.1)REMRESTDatabase
- remove()REM
- RemoveREM
- SQL生成AWR中的SQL ordered by Elapsed TimeSQL
- JavaScript remove()JavaScriptREM
- jQuery remove()jQueryREM
- Remove ElementREM
- Remove Element 解答REM
- DataTransferItemList.remove()REM
- Remove Unused ModulesREM
- JavaScript select remove()JavaScriptREM
- jQuery empty() vs remove()jQueryREM
- Timeout expired. The timeout period elapsed prior to completion of the operation or the server is noServer
- openmesh - impl - Remove Duplicated VerticesREM
- std::remove_if 介紹REM
- Docker remove all containersDockerREMAI
- Remove Invalid Parentheses[難]REM
- leetcode Remove ElementLeetCodeREM
- Remove Oracle Rac (11.2.0.1)REMOracle
- Remove Duplicates from Sorted ListREM
- 為什麼要removeREM
- [leetcode]remove-elementLeetCodeREM
- jQuery之empty()與remove()方法jQueryREM
- Remove-duplicates-from-sorted-listREM
- Java List的remove()方法陷阱JavaREM
- Remove-duplicates-from-sorted-arrayREM
- Remove Untagged Images From DockerREMDocker
- Leetcode-Remove ElementLeetCodeREM
- Remove Element leetcode javaREMLeetCodeJava
- c++的remove函式C++REM函式
- How to Find Out How Much Space an Index is UsingIndex
- SQLPlusSQL
- Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.Server
- How the web worksWeb
- How Google WorksGo