rem indX.sql - Indexed columns of 1 or more tables of 1 user
rem desc : Shows Indexed columns, uniqueness, distinct_keys.
rem usage: Enter a table_name or first 10 characters of a table_name.
rem Return gives ALL indexes of the user running the statement.
col table_name format A16 trunc
col index_name format A18 trunc
col column_name format A20 trunc
col column_position format 99 head 'Col|pos'
col uniqueness format A9 head 'Unique?'
col distinct_keys format 9999999 head 'Distinct|keys'
break on table_name skip 1
select I.table_name,I.index_name
,I.uniqueness,I.distinct_keys
,C.column_name,C.column_position
from USER_IND_COLUMNS C
,USER_INDEXES I
where C.index_name = I.index_name
and I.table_name like upper('&table_name%')
order by table_name,index_name,column_position
;
OUTPUT:
Distinct Col
TABLE_NAME INDEX_NAME Unique? keys COLUMN_NAME pos
---------------- ------------------ --------- -------- -------------------- ---
DEPT PK_DEPT UNIQUE DEPTNO 1
EMP PK_EMP UNIQUE EMPNO 1
rem desc : Shows Indexed columns, uniqueness, distinct_keys.
rem usage: Enter a table_name or first 10 characters of a table_name.
rem Return gives ALL indexes of the user running the statement.
col table_name format A16 trunc
col index_name format A18 trunc
col column_name format A20 trunc
col column_position format 99 head 'Col|pos'
col uniqueness format A9 head 'Unique?'
col distinct_keys format 9999999 head 'Distinct|keys'
break on table_name skip 1
select I.table_name,I.index_name
,I.uniqueness,I.distinct_keys
,C.column_name,C.column_position
from USER_IND_COLUMNS C
,USER_INDEXES I
where C.index_name = I.index_name
and I.table_name like upper('&table_name%')
order by table_name,index_name,column_position
;
OUTPUT:
Distinct Col
TABLE_NAME INDEX_NAME Unique? keys COLUMN_NAME pos
---------------- ------------------ --------- -------- -------------------- ---
DEPT PK_DEPT UNIQUE DEPTNO 1
EMP PK_EMP UNIQUE EMPNO 1
| 12-27 | 2850 | |||
| 12-11 | 2079 | |||
| 53 | 03-15 | 1917 | ||
| 52 | 01-31 | 2069 | ||
| 51 | 01-31 | 3032 | ||
| 50 | 01-31 | 1595 | ||
| 49 | 01-19 | 1923 | ||
| 48 | 01-11 | 1783 | ||
| 47 | 01-03 | 2383 | ||
| 46 | 12-27 | 2850 | ||
| 45 | 12-19 | 2003 | ||
| 44 | 12-14 | 1975 | ||
| 43 | 12-11 | 2079 | ||
| 42 | 12-09 | 1616 | ||
| 41 | 12-01 | 1836 | ||
| 40 | 12-01 | 2076 | ||
| 39 | 12-01 | 1492 | ||
댓글 없음:
댓글 쓰기