{"id":3297,"date":"2018-03-09T17:26:21","date_gmt":"2018-03-09T20:26:21","guid":{"rendered":"http:\/\/www.dbarj.com.br\/pkg_xdollar_search\/"},"modified":"2018-03-09T17:26:21","modified_gmt":"2018-03-09T20:26:21","slug":"pkg_xdollar_search","status":"publish","type":"page","link":"https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/","title":{"rendered":"PKG_XDOLLAR_SEARCH &#8211; Search in all X$ tables"},"content":{"rendered":"<p>This package is useful when you need to scan in some X$ table for a given value but don&#8217;t know exactly in which X$ table or column this value is.<\/p>\n<p>So this package will scan in ALL X$ and print in which table and column the given value was located.<\/p>\n<p>Remember that more scans on the memory means more CPU assumption, more latch acquisition and potential concurrency problem. So it&#8217;s\u00a0<strong>NOT<\/strong> recommended\u00a0to run this package in\u00a0<strong>PRODUCTION<\/strong>\u00a0environment.<\/p>\n<h1><strong>1. Installation<\/strong><\/h1>\n<p>Github link:\u00a0<a href=\"https:\/\/github.com\/dbarj\/pkg_xdollar_search\/\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/dbarj\/pkg_xdollar_search\/<\/a><\/p>\n<p>Download and unzip pkg_xdollar_search_master.zip, navigate to the root pkg_xdollar_search_master directory, and connect as SYS to deploy the package:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">$ wget -O pkg_xdollar_search.zip\u00a0https:\/\/github.com\/dbarj\/pkg_xdollar_search\/archive\/master.zip\r\n$ unzip pkg_xdollar_search.zip\r\n$ cd pkg_xdollar_search-master\r\n$ sqlplus \/ as sysdba @pkg_xdollar_search.sql<\/pre>\n<p>Now just execute the package:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"oracledb\">SQL&gt; select * from table(pkg_xdollar_search.f_string('DBARJ','X$KQ%'));\r\n\r\nTABLE_NAME COLUMN_NAME   ADDR             INDX CONTENTS SEARCH_QRY                                  EXEC_TIME_SECS\r\n---------- ------------- ---------------- ---- -------- ------------------------------------------- --------------\r\nX$KQLFBC   KQLFBC_STRVAL 00007F5E2B2CEA98   37 DBARJ    SELECT * FROM \"X$KQLFBC\" WHERE \"INDX\"=37;              .06\r\nX$KQLFBC   KQLFBC_STRVAL 00007F5E2B3739B8  918 DBARJ    SELECT * FROM \"X$KQLFBC\" WHERE \"INDX\"=918;             .06\r\nX$KQLFBC   KQLFBC_STRVAL 00007F5E2B58FEC8 3543 DBARJ    SELECT * FROM \"X$KQLFBC\" WHERE \"INDX\"=3543;            .06\r\nX$KQLFBC   KQLFBC_STRVAL 00007F5E2B41DB80 9853 DBARJ    SELECT * FROM \"X$KQLFBC\" WHERE \"INDX\"=9853;            .06<\/pre>\n<h1><strong>2.\u00a0Documentation<\/strong><\/h1>\n<p>The package has basically 7 functions and 3 variables:<\/p>\n<h3><strong>FUNCTIONS:<\/strong><\/h3>\n<ul>\n<li><strong>F_STRING<\/strong> : Search for a string value in VARCHAR2 X$ columns.<\/li>\n<li><strong>F_NUMBER<\/strong> : Search for a numeric value in NUMBER X$ columns.<\/li>\n<li><strong>F_RAW<\/strong> : Search for a raw value in RAW X$ columns.<\/li>\n<li><strong>F_DATE<\/strong> : Search for a date value in DATE X$ columns.<\/li>\n<li><strong>F_TIMESTAMP<\/strong> : Search for a timestamp value in TIMESTAMP X$ columns.<\/li>\n<li><strong>F_TIMESTAMPTZ<\/strong> : Search for a timestamp with time zone value in TIMESTAMP WITH TIME ZONE X$ columns.<\/li>\n<li><strong>F_CLOB<\/strong> : Search for a clob value in CLOB X$ columns.<\/li>\n<\/ul>\n<h3><strong>FUNCTION PARAMETERS:<\/strong><\/h3>\n<p>All functions above accept up to 3 parameters:<\/p>\n<ul>\n<li>1st param: <strong>p_input<\/strong> (mandatory) &#8211; The value that you are searching. For F_STRING, wild cards &#8216;%&#8217; are accepted. For F_CLOB, the value will always be searched as substr. For others, will do an exact match.<\/li>\n<li>2nd param: <strong>p_tab_name<\/strong> (optional) &#8211; You can optionally filter what X$ tables will be included in the search also using wild cards. By default, all are included: &#8216;X$%&#8217;<\/li>\n<li>3rd param: <strong>p_col_name<\/strong> (optional) &#8211; You can optionally filter what X$ columns will be included in the search also using wild cards. By default, all are included. &#8216;%&#8217;<\/li>\n<\/ul>\n<h3><strong>VARIABLES:<\/strong><\/h3>\n<p>You can also change some package variables to change the default behaviour of the program:<\/p>\n<ul>\n<li><strong>SKIP_DIAG<\/strong> (default TRUE) : By default the search functions will skip X$ tables starting with X$DIAG. Change to FALSE to include all.<\/li>\n<li><strong>SKIP_NONINDEXED<\/strong> (default FALSE) : By default the search functions will scan all X$ columns, including the non-indexed. Change to TRUE to skip them.<\/li>\n<li><strong>DEBUG<\/strong> (default FALSE) : Change to TRUE to enable DEBUG mode and see execution step by step in the query output.<\/li>\n<\/ul>\n<h1><strong>3. Usage Example<\/strong><\/h1>\n<p>All functions return a pipelined table in the following format:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Column Name    | Type           | Description\r\n-------------- | -------------  | -----------------------------------------------------\r\nTABLE_NAME     | VARCHAR2(30)   | X$ table where value was found.\r\nCOLUMN_NAME    | VARCHAR2(30)   | X$ column where value was found.\r\nADDR           | RAW(8)         | ADDR of X$ table.\r\nINDX           | NUMBER         | INDX of X$ table.\r\nCONTENTS       | VARCHAR2(4000) | Content found in the column.\r\nSEARCH_QRY     | VARCHAR2(1000) | Query to retrieve the entire row for the found value.\r\nEXEC_TIME_SECS | NUMBER         | Executed time in seconds.<\/pre>\n<h4>EXAMPLE<\/h4>\n<ul>\n<li>Searching in all X$ tables any column containing &#8216;DBARJ&#8217;.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_string(&#8216;%DBARJ%&#8217;));<\/span><\/p>\n<ul>\n<li>Searching in X$KQLFBC table any column with the exactly text &#8216;DBARJ&#8217;.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_string(&#8216;DBARJ&#8217;,&#8217;X$KQLFBC&#8217;));<\/span><\/p>\n<ul>\n<li>Searching for raw in all X$ tables starting with X$KC any column containing value &#8216;00000000B715CCB8&#8217;.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_raw(&#8216;00000000B715CCB8&#8242;,&#8217;X$KC%&#8217;));<\/span><\/p>\n<ul>\n<li>Searching for CLOB value.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; var myclob clob;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; exec :myclob := &#8216;Bind UACs mismatch&#8217;;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_clob(:myclob));<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">&#8212; OR<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_clob(&#8216;Bind UACs mismatch&#8217;));<\/span><\/p>\n<ul>\n<li>By default X$DIAG tables are skipped. To include them, change SKIP_DIAG variable to FALSE.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; exec pkg_xdollar_search.SKIP_DIAG := FALSE;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_string(&#8216;%DBARJ%&#8217;));<\/span><\/p>\n<ul>\n<li>Note that SKIP_DIAG variable is also ignored when table filters are used.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; exec pkg_xdollar_search.SKIP_DIAG := TRUE;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_string(&#8216;%DBARJ%&#8217;,&#8217;X$DIAG%&#8217;));<\/span><\/p>\n<ul>\n<li>It&#8217;s also possible to filter by column name instead of table name, using 3rd parameter.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_number(1234,NULL,&#8217;%INDX%&#8217;));<\/span><\/p>\n<ul>\n<li>By default, all X$ columns (indexed and non indexed) will be included in the output. However, if you wish to scan only on indexed columns, change SKIP_NONINDEXED to TRUE.\u00a0Note that indexed columns performs an &#8220;FIXED TABLE FIXED INDEX&#8221; vs &#8220;FIXED TABLE FULL&#8221; which generates less latches and thus less impact in the environment.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; exec pkg_xdollar_search.SKIP_NONINDEXED := TRUE;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_raw(&#8216;00000000B715CCB8&#8242;,&#8217;X$KC%&#8217;));<\/span><\/p>\n<h4>DEBUG<\/h4>\n<ul>\n<li>To debug the execution, change DEBUG variable to TRUE. Please note that all steps of package will be spooled.<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; exec pkg_xdollar_search.DEBUG := TRUE;<\/span><br \/>\n<span style=\"font-family: 'courier new', courier, monospace;\">SQL&gt; select * from table(pkg_xdollar_search.f_clob(&#8216;Bind UACs mismatch&#8217;));<\/span><\/p>\n<h4>MISC<\/h4>\n<ul>\n<li>All column types of X$ tables:<\/li>\n<\/ul>\n<p><span style=\"font-family: 'courier new', courier, monospace;\">SYS&gt; select kqfcodty,count(*) from x$kqfco group by kqfcodty order by 2 desc;<\/span><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">   KQFCODTY    COUNT(*)\r\n----------- -----------\r\n          2       13853 -- NUMBER\r\n          1        2906 -- VARCHAR2\r\n         23        1891 -- RAW\r\n         12         282 -- DATE\r\n        181         189 -- TIMESTAMP WITH TIME ZONE\r\n        180          40 -- TIMESTAMP\r\n        112          25 -- CLOB<\/pre>\n<h1><strong>4. Download<\/strong><\/h1>\n<p><a href=\"https:\/\/github.com\/dbarj\/pkg_xdollar_search\/archive\/master.zip\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/github.com\/dbarj\/pkg_xdollar_search\/archive\/master.zip<\/a><\/p>\n<b>Have you enjoyed? Please leave a comment or give a \ud83d\udc4d!<\/b>\n<div class='watch-action'><div class='watch-position align-left'><div class='action-like'><a class='lbg-style2 like-3297 jlk' href='javascript:void(0)' data-task='like' data-post_id='3297' data-nonce='de4404f630' rel='nofollow'><img class='wti-pixel' src='https:\/\/www.dbarj.com.br\/wp-content\/plugins\/wti-like-post\/images\/pixel.gif' title='Like' \/><span class='lc-3297 lc'>0<\/span><\/a><\/div><\/div> <div class='status-3297 status align-left'><\/div><\/div><div class='wti-clear'><\/div>","protected":false},"excerpt":{"rendered":"<p>This package is useful when you need to scan in some X$ table for a given value but don&#8217;t know exactly in which X$ table or column this value is. So this package will scan in ALL X$ and print in which table and column the given value was located. Remember that more scans on &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/\">Continue lendo<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3297","page","type-page","status-publish","hentry","nodate","item-wrap"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PKG_XDOLLAR_SEARCH - Search in all X$ tables - DBA - Rodrigo Jorge - Oracle Tips and Guides<\/title>\n<meta name=\"description\" content=\"This package is useful when you need to scan in some X$ table for a given value but don&#039;t know exactly in which X$ table or column this value is.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/\" \/>\n<meta name=\"twitter:label1\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/pkg_xdollar_search\\\/\",\"url\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/pkg_xdollar_search\\\/\",\"name\":\"PKG_XDOLLAR_SEARCH - Search in all X$ tables - DBA - Rodrigo Jorge - Oracle Tips and Guides\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/#website\"},\"datePublished\":\"2018-03-09T20:26:21+00:00\",\"description\":\"This package is useful when you need to scan in some X$ table for a given value but don't know exactly in which X$ table or column this value is.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/pkg_xdollar_search\\\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/pkg_xdollar_search\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/pkg_xdollar_search\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PKG_XDOLLAR_SEARCH - Search in all X$ tables\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/#website\",\"url\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/\",\"name\":\"DBA - Rodrigo Jorge - Oracle Tips and Guides\",\"description\":\"Blog about Databases, Security and High Availability\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/#\\\/schema\\\/person\\\/28a44ca3a6633fe4156ad1ea209d40a9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-BR\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/pt-br\\\/#\\\/schema\\\/person\\\/28a44ca3a6633fe4156ad1ea209d40a9\",\"name\":\"DBA RJ\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/wp-content\\\/uploads\\\/2019\\\/09\\\/RodrigoJorgePOUG19.png\",\"url\":\"https:\\\/\\\/www.dbarj.com.br\\\/wp-content\\\/uploads\\\/2019\\\/09\\\/RodrigoJorgePOUG19.png\",\"contentUrl\":\"https:\\\/\\\/www.dbarj.com.br\\\/wp-content\\\/uploads\\\/2019\\\/09\\\/RodrigoJorgePOUG19.png\",\"width\":712,\"height\":712,\"caption\":\"DBA RJ\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.dbarj.com.br\\\/wp-content\\\/uploads\\\/2019\\\/09\\\/RodrigoJorgePOUG19.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PKG_XDOLLAR_SEARCH - Search in all X$ tables - DBA - Rodrigo Jorge - Oracle Tips and Guides","description":"This package is useful when you need to scan in some X$ table for a given value but don't know exactly in which X$ table or column this value is.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/","twitter_misc":{"Est. tempo de leitura":"5 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/","url":"https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/","name":"PKG_XDOLLAR_SEARCH - Search in all X$ tables - DBA - Rodrigo Jorge - Oracle Tips and Guides","isPartOf":{"@id":"https:\/\/www.dbarj.com.br\/pt-br\/#website"},"datePublished":"2018-03-09T20:26:21+00:00","description":"This package is useful when you need to scan in some X$ table for a given value but don't know exactly in which X$ table or column this value is.","breadcrumb":{"@id":"https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbarj.com.br\/pt-br\/pkg_xdollar_search\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dbarj.com.br\/pt-br\/"},{"@type":"ListItem","position":2,"name":"PKG_XDOLLAR_SEARCH - Search in all X$ tables"}]},{"@type":"WebSite","@id":"https:\/\/www.dbarj.com.br\/pt-br\/#website","url":"https:\/\/www.dbarj.com.br\/pt-br\/","name":"DBA - Rodrigo Jorge - Oracle Tips and Guides","description":"Blog about Databases, Security and High Availability","publisher":{"@id":"https:\/\/www.dbarj.com.br\/pt-br\/#\/schema\/person\/28a44ca3a6633fe4156ad1ea209d40a9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbarj.com.br\/pt-br\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-BR"},{"@type":["Person","Organization"],"@id":"https:\/\/www.dbarj.com.br\/pt-br\/#\/schema\/person\/28a44ca3a6633fe4156ad1ea209d40a9","name":"DBA RJ","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/www.dbarj.com.br\/wp-content\/uploads\/2019\/09\/RodrigoJorgePOUG19.png","url":"https:\/\/www.dbarj.com.br\/wp-content\/uploads\/2019\/09\/RodrigoJorgePOUG19.png","contentUrl":"https:\/\/www.dbarj.com.br\/wp-content\/uploads\/2019\/09\/RodrigoJorgePOUG19.png","width":712,"height":712,"caption":"DBA RJ"},"logo":{"@id":"https:\/\/www.dbarj.com.br\/wp-content\/uploads\/2019\/09\/RodrigoJorgePOUG19.png"}}]}},"_links":{"self":[{"href":"https:\/\/www.dbarj.com.br\/pt-br\/wp-json\/wp\/v2\/pages\/3297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbarj.com.br\/pt-br\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.dbarj.com.br\/pt-br\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbarj.com.br\/pt-br\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbarj.com.br\/pt-br\/wp-json\/wp\/v2\/comments?post=3297"}],"version-history":[{"count":0,"href":"https:\/\/www.dbarj.com.br\/pt-br\/wp-json\/wp\/v2\/pages\/3297\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbarj.com.br\/pt-br\/wp-json\/wp\/v2\/media?parent=3297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}