게시일: Nov 30, 2011 12:12:17 AM
-- 아래는 제가 직접 만든 SQL인데, 당연히 다른 SQL을 활용해도 비슷한 결과를 얻을 수 있습니다.
☞ 테이블 정의서
select
a.TABLE_NAME TID
, b.COMMENTS TNM
, a.COLUMN_NAME CID
, c.COMMENTS CNM
, decode(a.DATA_TYPE, 'VARCHAR2' , 'VC2'
, 'NUMBER' , 'N'
, 'DATE' , 'D'
, a.DATA_TYPE) DTYPE
, decode(a.DATA_TYPE, 'NUMBER' , a.DATA_PRECISION||'.'||a.DATA_SCALE
, 'FLOAT' , a.DATA_PRECISION||'.'||a.DATA_SCALE
, a.DATA_LENGTH) DATA_LENGTH
, decode(a.NULLABLE, 'Y', null, 'N') NULLYN
, a.DATA_DEFAULT D_DEFAULT
, decode(d.CONSTRAINT_NAME, null, null
, d.CONSTRAINT_NAME||'('||d.POSITION||')') CONS_NM1
from
USER_CONS_COLUMNS d
, USER_COL_COMMENTS c
, USER_TAB_COMMENTS b
, USER_TAB_COLUMNS a
where
a.TABLE_NAME = upper('&table_name')
and a.COLUMN_NAME = nvl(upper('&column_name'), a.COLUMN_NAME)
and b.TABLE_NAME = a.TABLE_NAME
and c.TABLE_NAME = a.TABLE_NAME
and c.COLUMN_NAME = a.COLUMN_NAME
and d.TABLE_NAME(+) = a.TABLE_NAME
and d.COLUMN_NAME(+) = a.COLUMN_NAME
and d.CONSTRAINT_NAME(+) = a.TABLE_NAME||'_PK'
order by
d.POSITION
, a.COLUMN_ID;
☞ 인덱스 정보 살펴보기
select *
from user_ind_columns
where table_name = upper('&table_name')
order by index_name, column_position;
☞ 프로시저, 펑션등에서 특정 단어 찾기 (UNIX의 grep 명령어와 유사), 특정 컬럼을 어느 오브젝트에서 사용중인지 찾을 때 좋음.
select *
from user_source
where upper(text) like '%'||upper('&text')||'%';