[20210401]跟蹤sqlplus登入執行了什麼.txt
[20210401]跟蹤sqlplus登入執行了什麼.txt
--//昨天做了測試,連結http://blog.itpub.net/267265/viewspace-2765851/,順便記錄一下登入過程執行了什麼。
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
alter system set events 'sql_trace off';
alter system set events 'sql_trace [sql:cm5vu20fhtnq1|3nkd3g3ju5ph1|459f3z9u4fb3u|0ws7ahf1d78qa|5ur69atw3vfhj|0k8522rmdzg4k] bind=true, wait=true';
alter system set events '10046 trace name context forever, level 12';
--//使用sqlplus登入。
alter system set events 'sql_trace off';
2.測試結果如下:
$ extractsql.sh /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_51309.trc
select privilege# from sysauth$ where (grantee#=:1 or grantee#=1) and privilege#>0
select /*+ connect_by_filtering */ privilege#,level from sysauth$ connect by grantee#=prior privilege# and privilege#>0 start with grantee#=:1 and privilege#>0
ALTER SESSION SET NLS_LANGUAGE= 'AMERICAN' NLS_TERRITORY= 'AMERICA' NLS_CURRENCY= '$' NLS_ISO_CURRENCY= 'AMERICA' NLS_NUMERIC_CHARACTERS= '.,' NLS_CALENDAR= 'GREGORIAN' NLS_DATE_FORMAT= 'YYYY-MM-DD HH24:MI:SS' NLS_DATE_LANGUAGE= 'AMERICAN' NLS_SORT= 'BINARY' TIME_ZONE= '+08:00' NLS_COMP= 'BINARY' NLS_DUAL_CURRENCY= '$' NLS_TIME_FORMAT= 'HH.MI.SSXFF AM' NLS_TIMESTAMP_FORMAT= 'YYYY-MM-DD HH24:MI:SS.FF' NLS_TIME_TZ_FORMAT= 'HH.MI.SSXFF AM TZR' NLS_TIMESTAMP_TZ_FORMAT= 'YYYY-MM-DD HH24:MI:SS.FF TZH:TZM'
select value$ from props$ where name = 'GLOBAL_DB_NAME'
select SYS_CONTEXT('USERENV', 'SERVER_HOST'), SYS_CONTEXT('USERENV', 'DB_UNIQUE_NAME'), SYS_CONTEXT('USERENV', 'INSTANCE_NAME'), SYS_CONTEXT('USERENV', 'SERVICE_NAME'), INSTANCE_NUMBER, STARTUP_TIME, SYS_CONTEXT('USERENV', 'DB_DOMAIN') from v$instance where INSTANCE_NAME=SYS_CONTEXT('USERENV', 'INSTANCE_NAME')
select decode(failover_method, NULL, 0 , 'BASIC', 1, 'PRECONNECT', 2 , 'PREPARSE', 4 , 0), decode(failover_type, NULL, 1 , 'NONE', 1 , 'SESSION', 2, 'SELECT', 4, 1), failover_retries, failover_delay, flags from service$ where name = :1
--//前面6條執行的sqlplus來之oracle執行檔案內部,獲取連線使用者的許可權。
SELECT USER FROM DUAL
BEGIN DBMS_OUTPUT.DISABLE; END;
SELECT ATTRIBUTE,SCOPE,NUMERIC_VALUE,CHAR_VALUE,DATE_VALUE FROM SYSTEM.PRODUCT_PRIVS WHERE (UPPER('SQL*Plus') LIKE UPPER(PRODUCT)) AND (USER LIKE USERID)
SELECT CHAR_VALUE FROM SYSTEM.PRODUCT_PRIVS WHERE (UPPER('SQL*Plus') LIKE UPPER(PRODUCT)) AND ((USER LIKE USERID) OR (USERID = 'PUBLIC')) AND (UPPER(ATTRIBUTE) = 'ROLES')
BEGIN DBMS_APPLICATION_INFO.SET_MODULE(:1,NULL); END;
SELECT DECODE('A','A','1','2') FROM DUAL
3.繼續測試toad的情況是否一樣。
$ extractsql.sh book_ora_51333.trc
select privilege# from sysauth$ where (grantee#=:1 or grantee#=1) and privilege#>0
select /*+ connect_by_filtering */ privilege#,level from sysauth$ connect by grantee#=prior privilege# and privilege#>0 start with grantee#=:1 and privilege#>0
ALTER SESSION SET NLS_LANGUAGE= 'AMERICAN' NLS_TERRITORY= 'AMERICA' NLS_CURRENCY= '$' NLS_ISO_CURRENCY= 'AMERICA' NLS_NUMERIC_CHARACTERS= '.,' NLS_CALENDAR= 'GREGORIAN' NLS_DATE_FORMAT= 'YYYY-MM-DD HH24:MI:SS' NLS_DATE_LANGUAGE= 'AMERICAN' NLS_SORT= 'BINARY' TIME_ZONE= '+08:00' NLS_COMP= 'BINARY' NLS_DUAL_CURRENCY= '$' NLS_TIME_FORMAT= 'HH.MI.SSXFF AM' NLS_TIMESTAMP_FORMAT= 'YYYY-MM-DD HH24:MI:SS.FF' NLS_TIME_TZ_FORMAT= 'HH.MI.SSXFF AM TZR' NLS_TIMESTAMP_TZ_FORMAT= 'YYYY-MM-DD HH24:MI:SS.FF TZH:TZM'
select value$ from props$ where name = 'GLOBAL_DB_NAME'
select SYS_CONTEXT('USERENV', 'SERVER_HOST'), SYS_CONTEXT('USERENV', 'DB_UNIQUE_NAME'), SYS_CONTEXT('USERENV', 'INSTANCE_NAME'), SYS_CONTEXT('USERENV', 'SERVICE_NAME'), INSTANCE_NUMBER, STARTUP_TIME, SYS_CONTEXT('USERENV', 'DB_DOMAIN') from v$instance where INSTANCE_NAME=SYS_CONTEXT('USERENV', 'INSTANCE_NAME')
select decode(failover_method, NULL, 0 , 'BASIC', 1, 'PRECONNECT', 2 , 'PREPARSE', 4 , 0), decode(failover_type, NULL, 1 , 'NONE', 1 , 'SESSION', 2, 'SELECT', 4, 1), failover_retries, failover_delay, flags from service$ where name = :1
--//前面6條執行的sqlplus來之oracle執行檔案內部,獲取連線使用者的許可權。
declare cursor NlsParamsCursor is SELECT * FROM nls_session_parameters;begin SELECT Nvl(Lengthb(Chr(16777216)), Nvl(Lengthb(Chr(65536)), Nvl(Lengthb(Chr(256)), 1))), Nvl(Lengthb(Chr(1)), 1) INTO :MaxCharLength, :MinCharLength FROM dual; for NlsRecord in NlsParamsCursor loop if NlsRecord.parameter = 'NLS_DATE_LANGUAGE' then :NlsDateLanguage := NlsRecord.value; elsif NlsRecord.parameter = 'NLS_DATE_FORMAT' then :NlsDateFormat := NlsRecord.value; elsif NlsRecord.parameter = 'NLS_NUMERIC_CHARACTERS' then :NlsNumericCharacters := NlsRecord.value; elsif NlsRecord.parameter = 'NLS_TIMESTAMP_FORMAT' then :NlsTimeStampFormat := NlsRecord.value; elsif NlsRecord.parameter = 'NLS_TIMESTAMP_TZ_FORMAT' then :NlsTimeStampTZFormat := NlsRecord.value; end if; end loop;end;
SELECT NVL(LENGTHB(CHR(16777216)), NVL(LENGTHB(CHR(65536)), NVL(LENGTHB(CHR(256)), 1))), NVL(LENGTHB(CHR(1)), 1) FROM DUAL
SELECT * FROM NLS_SESSION_PARAMETERS
select /*+ index(idl_sb4$ i_idl_sb41) +*/ piece#,length,piece from idl_sb4$ where obj#=:1 and part=:2 and version=:3 order by piece#
select /*+ index(idl_ub1$ i_idl_ub11) +*/ piece#,length,piece from idl_ub1$ where obj#=:1 and part=:2 and version=:3 order by piece#
select /*+ index(idl_char$ i_idl_char1) +*/ piece#,length,piece from idl_char$ where obj#=:1 and part=:2 and version=:3 order by piece#
select /*+ index(idl_ub2$ i_idl_ub21) +*/ piece#,length,piece from idl_ub2$ where obj#=:1 and part=:2 and version=:3 order by piece#
begin sys.dbms_application_info.set_module('TOAD background query session', null); end;
select text from view$ where rowid=:1
select object_name nam, Decode(object_type, 'TABLE', 1, 'VIEW', 2, 3) typ
from sys.user_objects
where object_type in ('TABLE','PROCEDURE', 'PACKAGE', 'FUNCTION')
--//正如連線http://blog.itpub.net/4227/viewspace-708276測試awr報表那樣,如果一個應該不停的登入退出,沒有什麼負載的話,估
--//計看到的awr報表就是那樣。
4.收尾:
SYS@book> alter system set events '10046 trace name context off';
System altered.
SYS@book> alter system set events 'sql_trace off';
System altered.
5.附上extractsql.sh指令碼:
$ cat ~/bin/extractsql.sh
#! /bin/bash
awk '/PARSING IN CURSOR/,/END OF STMT/' $1 | egrep -v '^PARSING|^END OF STMT'
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2766041/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20211108]sqlplus 本地登入緩慢.txtSQL
- [20211109]sqlplus本地登入緩慢分析2.txtSQL
- [20190402]跟蹤vmstat.txt
- [20210603]如何跟蹤索引分裂.txt索引
- spring security之 預設登入頁原始碼跟蹤Spring原始碼
- [20231025]跟蹤rename操作2.txt
- 跟蹤執行命令T
- spring security 之自定義表單登入原始碼跟蹤Spring原始碼
- [20190401]跟蹤dbms_lock.sleep呼叫.txt
- [20211013]閱讀ldd原始碼跟蹤.txt原始碼
- [20181006]12c sqlplus顯示使用者上次登入時間.txtSQL
- [20230323]sqlplus #.txtSQL
- 一起來看看Babel到底執行了什麼?Babel
- [20190917]oracle跟蹤事件簡單寫法.txtOracle事件
- [20210220]gdb跟蹤邏輯讀2.txt
- sqlplus常用的幾種登入方式SQL
- sqlplus as sysdb登入報ora-01017SQL
- rmdev、chdev、reducevg、exportvg和importvg命令執行了什麼操作devExportImport
- [20200818]12c 10046跟蹤時間戳.txt時間戳
- 一個ssh無法遠端登入的問題跟蹤解決
- [20200219]strace跟蹤設定ENABLE=BROKEN的情況.txt
- [20200326]dbms_monitor跟蹤與SQL語句分析.txtSQL
- [20211011]跟蹤freespace空間的變化情況.txt
- Cookie 是什麼?從儲存登入到廣告追蹤的那些事Cookie
- []==''返回?為什麼?運算子==進行了什麼操作?
- [20191221]12c查詢跟蹤檔案內容.txt
- [20200818]12c 10046跟蹤時間戳2.txt時間戳
- [20240920]跟蹤library cache lock library cache pin使用gdb.txt
- [20240824]跟蹤library cache lock library cache pin使用gdb.txt
- [20190126]從sqlplus執行結果返回bash shell變數.txtSQL變數
- oracle windows sqlplus ora-01017 登入被拒絕OracleWindowsSQL
- [20190215]sqlplus set arraysize.txtSQL
- [20190524]sqlplus 與輸出&.txtSQL
- [20190530]sqlplus preliminary connection.txtSQL
- [20211125]sqlplus生成html格式.txtSQLHTML
- [20211108]sqlplus管道過濾.txtSQL
- [20211227]抽取跟蹤檔案中的繫結變數值.txt變數
- Oracle執行語句跟蹤 使用sql trace實現語句追蹤OracleSQL