|
Table Info SQL
--
-- tabdesc.sql
--
set pagesize 66
set echo off
set verify off
set feedback off
ttitle 'Table Description - Space Definition'
spool tabdesc.lst
set heading on
set verify off
column ts format a30
column ta format a30
column clu format a30
column pcf format 99999999999990
column pcu format 99999999999990
column int format 99,999,999,990
column mat format 99,999,999,990
column inx format 99,999,999,990
column nxt format 99,999,999,990
column mix format 99,999,999,990
column max format 99,999,999,990
column pci format 99999999999990
column num format 99,999,999,990
column blo format 99,999,999,990
column emp format 99,999,999,990
column avg format 99,999,999,990
column cha format 99,999,999,990
column rln format 99,999,999,990
column hdg format a30 newline
set heading off
select 'Table Name' hdg, TABLE_NAME ta,
'Tablespace Name' hdg, TABLESPACE_NAME ts,
'Cluster Name' hdg, CLUSTER_NAME clu,
'% Free' hdg, PCT_FREE pcf,
'% Used' hdg, PCT_USED pcu,
'Ini Trans' hdg, INI_TRANS int,
'Max Trans' hdg, MAX_TRANS mat,
'Initial Extent (K)' hdg, INITIAL_EXTENT/1024 inx,
'Next Extent (K)' hdg, NEXT_EXTENT/1024 nxt,
'Min Extents' hdg, MIN_EXTENTS mix,
'Max Extents' hdg, MAX_EXTENTS max,
'% Increase' hdg, PCT_INCREASE pci,
'Number of Rows' hdg, NUM_ROWS num,
'Number of Blocks' hdg, BLOCKS blo,
'Number of Empty Blocks' hdg, EMPTY_BLOCKS emp,
'Average Space' hdg, AVG_SPACE avg,
'Chain Count' hdg, CHAIN_CNT cha,
'Average Row Length' hdg, AVG_ROW_LEN rln
from user_tables
/
set heading on
set embedded off
break on tn skip 1
column tn format a20 heading 'Table Name'
column cn format a20 heading 'Column Name'
column fo format a15 heading 'Type'
column nu format a8 heading 'Null'
ttitle 'Table Description - Column Definition'
select table_name tn,
COLUMN_NAME cn,
DATA_TYPE ||
decode(DATA_TYPE,
'NUMBER',
'('||to_char(DATA_PRECISION)||
decode(DATA_SCALE,0,'',','||to_char(DATA_SCALE))||')',
'VARCHAR2',
'('||to_char(DATA_LENGTH)||')',
'CHAR',
'('||to_char(DATA_LENGTH)||')',
'DATE','',
'Error') fo,
decode(NULLABLE,'Y','','NOT NULL') nu
FROM user_tab_columns
order by table_name,COLUMN_ID
/
exit
|