Question

I'm recently assigned to fill in the role of DBA (temporary). I'm a developer, so I'm not capable of many knowledges in Oracle... but today, while monitoring activities, I see the following SQL being performed from a developer's work station (TOAD.EXE). Is this something auto generated by Toad somehow or is the query being manually written? The reason is, i'm concerned about an individual have the privilege to select from SYS schema.

I've consulted with the developer, and he says they do not query sys tables nor have the need. So I'm a bit concerned as to how this query was generated.

Any advice is appreciate it. Thanks!

SELECT INDEX_NAME "Index Name",
       INDEX_TYPE "Index Type",
       UNIQUENESS "Uniqueness",
       STATUS "Status",
       TABLE_OWNER || '.' || TABLE_NAME "Table",
       TABLE_TYPE "Table Type",
       TABLESPACE_NAME "Tablespace",
       BUFFER_POOL "Buffer Pool",
       INITCAP (partitioned) "Partitioned",
       DECODE (temporary, 'N', 'No', 'Yes') "Temporary",
       INI_TRANS "Initial Transactions",
       MAX_TRANS "Max Transactions",
       INITIAL_EXTENT "Initial Extent Size",
       NEXT_EXTENT "Next Extent Size",
       MIN_EXTENTS "Minimum Extents",
       MAX_EXTENTS "Maximum Extents",
       PCT_INCREASE "Percent Increase",
       PCT_FREE "Percent Free",
       FREELISTS "Freelists",
       FREELIST_GROUPS "Freelist Groups",
       DEGREE "Degree",
       INSTANCES "Instances",
       LAST_ANALYZED "Last Analyzed",
       BLEVEL "BLevel",
       LEAF_BLOCKS "Leaf Blocks",
       DISTINCT_KEYS "Distinct Keys",
       AVG_LEAF_BLOCKS_PER_KEY "Avg Leaf Blocks Per Key",
       AVG_DATA_BLOCKS_PER_KEY "Avg Data Blocks Per Key",
       CLUSTERING_FACTOR "Clustering Factor",
       NUM_ROWS "Num Rows",
       SAMPLE_SIZE "Sample Size",
       GENERATED "Generated",
       DECODE (JOIN_INDEX, 'NO', 'No', 'Yes') "Join Index",
       Visibility "Visibility"
  FROM SYS.ALL_INDEXES
 WHERE OWNER = :OO AND INDEX_NAME = :NN
Was it helpful?

Solution

TOAD is generating a query against Oracle's data dictionary. Someone clicked on an index in TOAD and this is the query it generated. The name and owner of the index will be supplied via bind variables (the :OO and :NN)

Note that:

SELECT ... FROM SYS.ALL_INDEXES 

is the same as

SELECT ... FROM ALL_INDEXES

which is a view available to all users showing information about indexes that are visible to the current user (who you're connected as.)

If you're not familiar with the dictionary views (the USER_, ALL_, and DBA_* views), even as a developer you should start with:

http://docs.oracle.com/cd/E11882_01/server.112/e25789/datadict.htm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top