/* ***************************************************************** */
/* * * */
/* * MODULE: ALLCOL01.SQL * */
/* * AUTHOR: TONY DELIA. * */
/* * DATE: 08/27/96. * */
/* * DESC: ALL TABLE COLUMNS 01. * */
/* * USAGE: start allcol01 <table name> <owner> * */
/* * * */
/* ***************************************************************** */
START rptbeg02.sql
TTITLE 'ALL_TAB_COLUMNS Describe ALLCOL01.SQL' SKIP 2 -
'Table: ' ttab SKIP 2
COL htab NEW_VALUE ttab NOPRINT
COL hcol HEADING 'Name' FORMAT A31
COL hnul HEADING 'Null?' FORMAT A8
COL htyp HEADING 'Type' FORMAT A16
COL hid HEADING 'ID#' FORMAT 999
COL hdis HEADING 'Distinct|Rows' FORMAT 999,999
BREAK ON REPORT ON htab SKIP PAGE
COMPUTE COUNT OF hcol ON REPORT
COMPUTE COUNT OF hcol ON htab
/* ***************************************************************** */
/* * Select Table Columns * */
/* ***************************************************************** */
SELECT table_name htab,
column_name hcol,
DECODE(nullable,'N','NOT NULL',NULL) hnul,
data_type ||
DECODE(data_type,
'DATE',NULL,
'LONG',NULL,
'NUMBER',
DECODE(data_precision,
NULL,DECODE(data_scale,
NULL,NULL,'(38)'),
'(' || TO_CHAR(data_precision) ||
DECODE(data_scale,
NULL,NULL,
','||TO_CHAR(data_scale) ) || ')' ),
'(' || TO_CHAR(data_length) || ')' ) htyp,
column_id hid,
num_distinct hdis
FROM all_tab_columns
WHERE table_name LIKE UPPER('&&1')
AND owner = UPPER('&&2')
ORDER BY table_name ASC,
column_id ASC
/* ***************************************************************** */
/
START rptend01.sql
/* ***************************************************************** */
/* * END OF SQL PROGRAM * */
/* ***************************************************************** */
|