Oracle Sqlplus引數設定
oracle 11g在%oracle_home%/sqlplus/admin/下面會有一個glogin.sql檔案,每次sqlplus啟動的時候都會查詢並執行這個檔案,可以用這個檔案來儲存一些設定。讀完glogin.sql這個檔案之後,oracle還會查詢login.sql這個檔案,這是10G以及以上版本新新增的,這個檔案通常被放置在%oracle_home%/sqlplus/admin/下sqlplus 每次啟動前,會讀login.sql(若有的話) ,然後才是glogin.sql,login.sql只對某特定使用者生效,它的優先順序高於glogin.sql,glogin.sql是全域性設定。
所以,同一個環境變數,比如linesize ,glogin.sql 和login.sql 都有設定,則login.sql 中的設定起作用。glogin.sql 的檔案位置固定,在$ORACLE_HOME/sqlplus/admin 下面login.sql的位置不固定,一般將login.sql放在執行sqlplus 的當前目錄(用pwd檢視當前目錄),即:/home/oralce。
serveroutput
dbms_output.put_line將必要的資訊輸出,以便對儲存過程進行除錯,只有將serveroutput變數設為on後,資訊才能顯示在螢幕上。
pagesize
頁面顯示行數
show pagesize;
set pagesize 50;
linesize
行寬度預設是80
show linesize;
set linesize 100;
trimspool
set trimspool on
去除重定向(spool)輸出每行的拖尾空格,預設為off
修改頁面顯示和行的預設值,但是這種方法,在你下次進入Sql Plus的時候還要重新設定,很麻煩。所以可以修改預設設定。在Oracle的安裝目錄下找到glogin.sql,我安裝的是Oracle 11,這個檔案在11.2.0\dbhome\sqlplus\admin下,用搜索很容易找到。然後開啟這個檔案,
set serveroutput on size 1000000
set trimspool on
set long 5000
set linesize 100
set pagesize 9999
set linesize 154
col GROUP# for 99
col THREAD# for 99
col SEQUENCE# for 9999
col MEMBER for a50
col MEMBERS for 99
col name for a35
col username for a15
col file_name for a45
col tablespace_name for a30
col MACHINE for a30
col program for a34
col sid for 9999
col spid for a8
col value for a50
col COMMENTS for a50
col object_owner for a20
col object_name for a30
col TABLE_OWNER for a20
col TABLE_NAME for a30
col COLUMN_NAME for a30
col owner for a15;
col table_owner for a15
col index_type for a10
col DB_BLOCK_SIZE for a20
col UNDO_RETENTION for a30
col sql_text for a74
col text for a60
col r_owner for a15
col index_owner for a15
col GRANTEE for a15
col GRANTOR for a15
col PRIVILEGE for a35
col PROPERTY_VALUE for a50
col LAST_RUN_DURATION for a28
col DEST_NAME for a20
col DESTINATION for a30
col PLAN_TABLE_OUTPUT for a130
col SCHEMA_NAME for a20
col OCCUPANT_NAME for a30
col MOVE_PROCEDURE for a35
col DESCRIPTION for a50
col p1 for a30
col p2 for a30
col p3 for a30
col p3text for a46
col p2text for a46
col OPERATION for a50
col OPTIONS for a50
col statement for a88
col object for a50
col error for a35
col ARCHIVE_NAME for a40
col segment_name for a25
col segment_type for a25
col COMPONENT for a25
col parameter1 for a35
col parameter2 for a35
col parameter3 for a35
col sql_redo for a90
col sql_undo for a90
col log_user for a10
col priv_user for a10
col schema_user for a11
col INTERVAL for a20
col what for a48
col seg_name for a30
col SQL_REDO for a90
col pval2 for a50
col event for a50
col dest_name for a30
col p1 for 99999999999999
col p2 for 99999999999999
col p3 for 99999999999999
col maxbytes for 999999999999999999
col MODE_REQUESTED for a30
col MODE_HELD for a30
col OPERATION for a30
col options for a30
--排程相關
COL JOB_NAME for A15
COL JOB_CREATOR for A11
COL PROGRAM_OWNER for A11
COL PROGRAM_NAME FOR A12
COL SCHEDULE_NAME FOR A15
COL SCHEDULE_OWNER FOR A14;
col SCHEDULE_TYPE for a13
COL RESOURCE_PLAN FOR A13;
COL JOB_CLASS FOR A20
col START_DATE for a20
col END_DATE FOR a19
col PROGRAM_ACTION for a45
col COMMENTS for a15
col WINDOW_NAME for a20
col REPEAT_INTERVAL for a22
col DURATION for a20
col NEXT_START_DATE for a18
col DURATION for a8
col LAST_START_DATE for a18
col job_action for a10
col job_type for a10
column plan_plus_exp format a80
column global_name new_value gname
set termout off
define gname=idle
column global_name new_value gname
select lower(user) || '@' || substr( global_name, 1, decode( dot, 0,length(global_name), dot-1) ) global_name
from (select global_name, instr(global_name,'.') dot from global_name );
set sqlprompt '&gname> '
set termout on