Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL query
Vandana,
Put this into a script, save to hard drive, and run from sqlplus using "@path\script":
SET ECHO OFF
accept table_name prompt "Enter the name of the Table
:"
set heading on
set verify on
set newpage 0
ttitle 'Table Description - Space Definition'
spool tfstbdsc.lst
btitle off
column nline newline
set pagesize 54
set linesize 78
set heading off
set embedded off
set verify off
accept report_comment char prompt 'Enter a comment to
identify system: '
select 'Date - '||to_char(sysdate,'Day Ddth Month
YYYY HH24:MI:SS'),
'At - '||'&&report_comment' nline,
'Username - '||USER nline
from sys.dual /
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 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
select 'Table Name' hdg, TABLE_NAME ta, 'Tablespace Name' hdg, TABLESPACE_NAME ts,from all_tables
'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
select 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)||')', 'DATE','', 'Error') fo, decode(NULLABLE,'Y','','NOT NULL') nu, NUM_DISTINCT nds, DEFAULT_LENGTH dfl, DATA_DEFAULT dfv
select cns.CONSTRAINT_NAME cn, cns.TABLE_NAME||'.'||cls.COLUMN_NAME cln, initcap(cns.STATUS) st from all_constraints cns, all_cons_columns cls where cns.table_name=upper('&&table_name') and cns.owner=user and cns.CONSTRAINT_TYPE='P' and cns.constraint_name=cls.constraint_nameorder by cls.position
select cns.CONSTRAINT_NAME cn, cns.TABLE_NAME||'.'||cls.COLUMN_NAME cln, initcap(cns.STATUS) st from all_constraints cns, all_cons_columns cls where cns.table_name=upper('&&table_name') and cns.owner=user and cns.CONSTRAINT_TYPE='U' and cns.constraint_name=cls.constraint_nameorder by cls.position
select cns.CONSTRAINT_NAME cn, initcap(STATUS) st, cls.TABLE_NAME||'.'||cls.COLUMN_NAME cln, clf.OWNER||'.'||clf.TABLE_NAME||'.'||clf.COLUMN_NAME clfn from all_constraints cns, all_cons_columns clf , all_cons_columns cls where cns.table_name=upper('&&table_name') and cns.owner=user and cns.CONSTRAINT_TYPE='R' and cns.constraint_name=cls.constraint_name and clf.CONSTRAINT_NAME = cns.R_CONSTRAINT_NAME and clf.OWNER = cns.OWNER and clf.POSITION = clf.POSITION
initcap(STATUS) st, SEARCH_CONDITION se
initcap(STATUS) st, SEARCH_CONDITION se
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Jack Silvey INET: jack_silvey_at_yahoo.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Sat Jul 13 2002 - 11:18:23 CDT
![]() |
![]() |