SET TERMOUT ON
SET ECHO OFF
SET HEADING OFF
set LINESIZE 1000
set pagesize 0



ACCEPT Server PROMPT 'Enter a server alias/connection string (MAGICASH): ' DEFAULT MAGICASH 
ACCEPT SYSUSER PROMPT 'Enter SYS USER (SYS): ' DEFAULT SYS
ACCEPT SYSPsw PROMPT 'Enter SYS PASSWORD: ' DEFAULT NCTSYS

connect &SYSUSER/&SYSPsw@&Server as sysdba

spool Exp_scheme.bat

Prompt SET NLS_LANG=AMERICAN_AMERICA.CL8MSWIN1251

Prompt 
Prompt 
Prompt 
Prompt 

prompt Set v_sid=&Server
prompt Set v_username=&SYSUSER
prompt Set v_pass=&SYSPsw

Prompt 
Prompt 
Prompt 

SELECT 'exp.exe userid=' ||
       '''%v_username%/%v_pass%@%v_sid% as sysdba''' || ' FILE=results_ALL\DMP\' ||
       'exp_' || t.USERNAME || '.dmp' || ' LOG=results_ALL\LOG\' || 'exp_' ||
       t.USERNAME || '.log ' || 'OWNER=' || t.USERNAME || ' GRANTS=y' ||
       ' INDEXES=y' || ' ROWS=y' || ' CONSTRAINTS=y' || ' COMPRESS=y' ||
       ' STATISTICS=none' || ' FEEDBACK=5000000'
  FROM DBA_USERS t,
       (SELECT owner,
               TO_CHAR(ROUND(SUM(BYTES) / 1024 / 1024, 1)) || ' Mb' sch_size
          FROM dba_segments t1
         GROUP BY owner) objsize
 WHERE objsize.owner = t.username
   and ACCOUNT_STATUS = 'OPEN'
   and DEFAULT_TABLESPACE not in ('SYSTEM', 'SYSAUX')
 order by t.USERNAME asc;



prompt rename Exp_scheme.bat Exp_scheme.txt



SET TERMOUT ON
SET ECHO ON
EXIT  
 
