spool "C:\ACCDMD\basura\&1_table.csv"
select 'OWNER'||'|'||'TABLE_NAME'||'|'||'TABLESPACE_NAME'||'|'||'CLUSTER_NAME'||'|'||'IOT_NAME'||'|'||'STATUS'||'|'||
'PCT_FREE'||'|'||'PCT_USED'||'|'||'INI_TRANS'||'|'||'MAX_TRANS'||'|'||'INITIAL_EXTENT'||'|'||'NEXT_EXTENT'||'|'||
'MIN_EXTENTS'||'|'||'MAX_EXTENTS'||'|'||'PCT_INCREASE'||'|'||'FREELISTS'||'|'||'FREELIST_GROUPS'||'|'||'LOGGING'||'|'||
'BACKED_UP'||'|'||'NUM_ROWS'||'|'||'BLOCKS'||'|'||'EMPTY_BLOCKS'||'|'||'AVG_SPACE'||'|'||'CHAIN_CNT'||'|'||'AVG_ROW_LEN'||'|'||
'AVG_SPACE_FREELIST_BLOCKS'||'|'||'NUM_FREELIST_BLOCKS'||'|'||'DEGREE'||'|'||'INSTANCES'||'|'||'CACHE'||'|'||'TABLE_LOCK'||'|'||
'SAMPLE_SIZE'||'|'||'LAST_ANALYZED'||'|'||'PARTITIONED'||'|'||'IOT_TYPE'||'|'||'TEMPORARY'||'|'||'SECONDARY'||'|'||'NESTED'||'|'||
'BUFFER_POOL'||'|'||'ROW_MOVEMENT'||'|'||'GLOBAL_STATS'||'|'||'USER_STATS'||'|'||'DURATION'||'|'||'SKIP_CORRUPT'||'|'||'MONITORING'||'|'||
'CLUSTER_OWNER'||'|'||'DEPENDENCIES'||'|'||'COMPRESSION'||'|'||'DROPPED'
from dual;


SELECT OWNER||'|'||TABLE_NAME||'|'||TABLESPACE_NAME||'|'||CLUSTER_NAME||'|'||IOT_NAME||'|'||STATUS||'|'||PCT_FREE||'|'||
PCT_USED||'|'||INI_TRANS||'|'||MAX_TRANS||'|'||INITIAL_EXTENT||'|'||NEXT_EXTENT||'|'||MIN_EXTENTS||'|'||MAX_EXTENTS||'|'||
PCT_INCREASE||'|'||FREELISTS||'|'||FREELIST_GROUPS||'|'||LOGGING||'|'||BACKED_UP||'|'||NUM_ROWS||'|'||BLOCKS||'|'||EMPTY_BLOCKS||'|'||
AVG_SPACE||'|'||CHAIN_CNT||'|'||AVG_ROW_LEN||'|'||AVG_SPACE_FREELIST_BLOCKS||'|'||NUM_FREELIST_BLOCKS||'|'||DEGREE||'|'||
INSTANCES||'|'||CACHE||'|'||TABLE_LOCK||'|'||SAMPLE_SIZE||'|'||LAST_ANALYZED||'|'||PARTITIONED||'|'||IOT_TYPE||'|'||
TEMPORARY||'|'||SECONDARY||'|'||NESTED||'|'||BUFFER_POOL||'|'||ROW_MOVEMENT||'|'||GLOBAL_STATS||'|'||USER_STATS||'|'||
DURATION||'|'||SKIP_CORRUPT||'|'||MONITORING||'|'||CLUSTER_OWNER||'|'||DEPENDENCIES||'|'||COMPRESSION||'|'||DROPPED
FROM DBA_TABLES WHERE OWNER = '&1' 
ORDER BY TABLE_NAME;
spool off;


spool "C:\ACCDMD\basura\&1_table_columns.csv"
select 'OWNER'||'|'||'TABLE_NAME'||'|'||'COLUMN_NAME'||'|'||'DATA_TYPE'||'|'||'DATA_TYPE_MOD'||'|'||'DATA_TYPE_OWNER'||'|'||
'DATA_LENGTH'||'|'||'DATA_PRECISION'||'|'||'DATA_SCALE'||'|'||'NULLABLE'||'|'||'COLUMN_ID'||'|'||'DEFAULT_LENGTH'||'|'||
'DATA_DEFAULT'||'|'||'NUM_DISTINCT'||'|'||'LOW_VALUE'||'|'||'HIGH_VALUE'||'|'||'DENSITY'||'|'||'NUM_NULLS'||'|'||
'NUM_BUCKETS'||'|'||'LAST_ANALYZED'||'|'||'SAMPLE_SIZE'||'|'||'CHARACTER_SET_NAME'||'|'||'CHAR_COL_DECL_LENGTH'||'|'||
'GLOBAL_STATS'||'|'||'USER_STATS'||'|'||'AVG_COL_LEN'||'|'||'CHAR_LENGTH'||'|'||'CHAR_USED'||'|'||'V80_FMT_IMAGE'||'|'||
'DATA_UPGRADED'||'|'||'HISTOGRAM'
from dual;

SELECT OWNER||'|'||TABLE_NAME||'|'||COLUMN_NAME||'|'||DATA_TYPE||'|'||DATA_TYPE_MOD||'|'||DATA_TYPE_OWNER||'|'||
DATA_LENGTH||'|'||DATA_PRECISION||'|'||DATA_SCALE||'|'||NULLABLE||'|'||COLUMN_ID||'|'||DEFAULT_LENGTH||'|'||
DATA_DEFAULT||'|'||NUM_DISTINCT||'|'||LOW_VALUE||'|'||HIGH_VALUE||'|'||DENSITY||'|'||NUM_NULLS||'|'||NUM_BUCKETS||'|'||
LAST_ANALYZED||'|'||SAMPLE_SIZE||'|'||CHARACTER_SET_NAME||'|'||CHAR_COL_DECL_LENGTH||'|'||GLOBAL_STATS||'|'||USER_STATS||'|'||
AVG_COL_LEN||'|'||CHAR_LENGTH||'|'||CHAR_USED||'|'||V80_FMT_IMAGE||'|'||DATA_UPGRADED||'|'||HISTOGRAM
FROM DBA_TAB_COLUMNS WHERE OWNER = '&1' 
ORDER BY TABLE_NAME, COLUMN_ID;

spool "C:\ACCDMD\basura\&1_index.csv"
select 'OWNER'||'|'||'INDEX_NAME'||'|'||'INDEX_TYPE'||'|'||'TABLE_OWNER'||'|'||'TABLE_NAME'||'|'||'TABLE_TYPE'||'|'||
'UNIQUENESS'||'|'||'COMPRESSION'||'|'||'PREFIX_LENGTH'||'|'||'TABLESPACE_NAME'||'|'||'INI_TRANS'||'|'||'MAX_TRANS'||'|'||
'INITIAL_EXTENT'||'|'||'NEXT_EXTENT'||'|'||'MIN_EXTENTS'||'|'||'MAX_EXTENTS'||'|'||'PCT_INCREASE'||'|'||'PCT_THRESHOLD'||'|'||
'INCLUDE_COLUMN'||'|'||'FREELISTS'||'|'||'FREELIST_GROUPS'||'|'||'PCT_FREE'||'|'||'LOGGING'||'|'||'BLEVEL'||'|'||'LEAF_BLOCKS'||'|'||
'DISTINCT_KEYS'||'|'||'AVG_LEAF_BLOCKS_PER_KEY'||'|'||'AVG_DATA_BLOCKS_PER_KEY'||'|'||'CLUSTERING_FACTOR'||'|'||'STATUS'||'|'||
'NUM_ROWS'||'|'||'SAMPLE_SIZE'||'|'||'LAST_ANALYZED'||'|'||'DEGREE'||'|'||'INSTANCES'||'|'||'PARTITIONED'||'|'||'TEMPORARY'||'|'||
'GENERATED'||'|'||'SECONDARY'||'|'||'BUFFER_POOL'||'|'||'USER_STATS'||'|'||'DURATION'||'|'||'PCT_DIRECT_ACCESS'||'|'||
'ITYP_OWNER'||'|'||'ITYP_NAME'||'|'||'PARAMETERS'||'|'||'GLOBAL_STATS'||'|'||'DOMIDX_STATUS'||'|'||'DOMIDX_OPSTATUS'||'|'||
'FUNCIDX_STATUS'||'|'||'JOIN_INDEX'||'|'||'IOT_REDUNDANT_PKEY_ELIM'||'|'||'DROPPED'
from dual;

SELECT OWNER||'|'||INDEX_NAME||'|'||INDEX_TYPE||'|'||TABLE_OWNER||'|'||TABLE_NAME||'|'||TABLE_TYPE||'|'||UNIQUENESS||'|'||
COMPRESSION||'|'||PREFIX_LENGTH||'|'||TABLESPACE_NAME||'|'||INI_TRANS||'|'||MAX_TRANS||'|'||INITIAL_EXTENT||'|'||NEXT_EXTENT||'|'||
MIN_EXTENTS||'|'||MAX_EXTENTS||'|'||PCT_INCREASE||'|'||PCT_THRESHOLD||'|'||INCLUDE_COLUMN||'|'||FREELISTS||'|'||
FREELIST_GROUPS||'|'||PCT_FREE||'|'||LOGGING||'|'||BLEVEL||'|'||LEAF_BLOCKS||'|'||DISTINCT_KEYS||'|'||
AVG_LEAF_BLOCKS_PER_KEY||'|'||AVG_DATA_BLOCKS_PER_KEY||'|'||CLUSTERING_FACTOR||'|'||STATUS||'|'||NUM_ROWS||'|'||
SAMPLE_SIZE||'|'||LAST_ANALYZED||'|'||DEGREE||'|'||INSTANCES||'|'||PARTITIONED||'|'||TEMPORARY||'|'||GENERATED||'|'||
SECONDARY||'|'||BUFFER_POOL||'|'||USER_STATS||'|'||DURATION||'|'||PCT_DIRECT_ACCESS||'|'||ITYP_OWNER||'|'||ITYP_NAME||'|'||
PARAMETERS||'|'||GLOBAL_STATS||'|'||DOMIDX_STATUS||'|'||DOMIDX_OPSTATUS||'|'||FUNCIDX_STATUS||'|'||JOIN_INDEX||'|'||
IOT_REDUNDANT_PKEY_ELIM||'|'||DROPPED
FROM DBA_INDEXES WHERE OWNER = '&1' 
ORDER BY TABLE_NAME, INDEX_NAME;
spool off;

spool "C:\ACCDMD\basura\&1_index_columns.csv"
select 'INDEX_OWNER'||'|'||'INDEX_NAME'||'|'||'TABLE_OWNER'||'|'||'TABLE_NAME'||'|'||'COLUMN_NAME'||'|'||'COLUMN_POSITION'||'|'||
'COLUMN_LENGTH'||'|'||'CHAR_LENGTH'||'|'||'DESCEND'||'|'||
from dual;

SELECT INDEX_OWNER||'|'||INDEX_NAME||'|'||TABLE_OWNER||'|'||TABLE_NAME||'|'||COLUMN_NAME||'|'||COLUMN_POSITION||'|'||
COLUMN_LENGTH||'|'||CHAR_LENGTH||'|'||DESCEND
FROM DBA_IND_COLUMNS WHERE INDEX_OWNER = '&1' 
ORDER BY TABLE_NAME, INDEX_NAME,COLUMN_POSITION;
spool off;

spool "C:\ACCDMD\basura\&1_constraints.csv"
select 'OWNER'||'|'||'CONSTRAINT_NAME'||'|'||'CONSTRAINT_TYPE'||'|'||'TABLE_NAME'||'|'||'SEARCH_CONDITION'||'|'||'R_OWNER'||'|'||
'R_CONSTRAINT_NAME'||'|'||'DELETE_RULE'||'|'||'STATUS'||'|'||'DEFERRABLE'||'|'||'DEFERRED'||'|'||'VALIDATED'||'|'||'GENERATED'||'|'||
'BAD'||'|'||'RELY'||'|'||'LAST_CHANGE'||'|'||'INDEX_OWNER'||'|'||'INDEX_NAME'||'|'||'INVALID'||'|'||'VIEW_RELATED'
from dual;

SELECT OWNER||'|'||CONSTRAINT_NAME||'|'||CONSTRAINT_TYPE||'|'||TABLE_NAME||'|'||SEARCH_CONDITION||'|'||
R_OWNER||'|'||R_CONSTRAINT_NAME||'|'||DELETE_RULE||'|'||STATUS||'|'||DEFERRABLE||'|'||DEFERRED||'|'||VALIDATED||'|'||
GENERATED||'|'||BAD||'|'||RELY||'|'||LAST_CHANGE||'|'||INDEX_OWNER||'|'||INDEX_NAME||'|'||INVALID||'|'||VIEW_RELATED
FROM DBA_CONSTRAINTS WHERE OWNER = '&1' ORDER BY TABLE_NAME, CONSTRAINT_NAME
spool off;

spool "C:\ACCDMD\basura\&1_constraints_columns.csv"
select 'OWNER'||'|'||'CONSTRAINT_NAME'||'|'||'TABLE_NAME'||'|'||'COLUMN_NAME'||'|'||'POSITION'||'|'||
from dual;

SELECT OWNER||'|'||CONSTRAINT_NAME||'|'||TABLE_NAME||'|'||COLUMN_NAME||'|'||POSITION||'|'|| 
FROM DBA_CONS_COLUMNS WHERE OWNER = '&1' ORDER BY TABLE_NAME, CONSTRAINT_NAME,POSITION;
spool off;

