PROMPT Por Favor ingrese los siguientes Datos ( CTRL + C para cancelar ):
accept pathData char prompt '    Ubicaci�n datafiles de Datos   (BOD_DATA_?): ';
accept pathIndx char prompt '    Ubicaci�n datafiles de Indices (BOD_INDX_?): ';
accept passSys  char prompt '    Contrase�a usuario SYS : ';
accept passSystem  char prompt '    Contrase�a usuario SYSTEM : ';

PROMPT --> Creando Tablespace BOD_DATA_D_1 en &pathData
CREATE TABLESPACE BOD_DATA_D_1 
    LOGGING
    DATAFILE '&pathData/bod_data_d_1.dbf' SIZE 500M
    AUTOEXTEND ON NEXT 200M
    MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL
    SEGMENT SPACE MANAGEMENT AUTO;

PROMPT --> Creando Tablespace BOD_DATA_H_1 en &pathData

CREATE TABLESPACE BOD_DATA_H_1
    LOGGING
    DATAFILE '&pathData/bod_data_h_1.dbf' SIZE 1500M
    AUTOEXTEND ON NEXT  100M
    MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL
    SEGMENT SPACE MANAGEMENT AUTO;

PROMPT --> Creando Tablespace BOD_DATA_H_10 en &pathData

CREATE TABLESPACE BOD_DATA_H_10
    LOGGING
    DATAFILE '&pathData/bod_data_h_10.dbf' SIZE 1500M
    AUTOEXTEND ON NEXT  100M
    MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 10M
    SEGMENT SPACE MANAGEMENT AUTO;

PROMPT --> Creando Tablespace BOD_DATA_H_100 en &pathData

CREATE TABLESPACE BOD_DATA_H_100
    LOGGING
    DATAFILE '&pathData/bod_data_h_100.dbf' SIZE 2500M
    AUTOEXTEND ON NEXT  200M
    MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 100M
    SEGMENT SPACE MANAGEMENT AUTO;

PROMPT --> Creando Tablespace BOD_INDX_D_1 en &pathIndx

CREATE TABLESPACE BOD_INDX_D_1
    LOGGING
    DATAFILE '&pathIndx/bod_indx_d_1.dbf' SIZE 500M
    AUTOEXTEND ON NEXT  100M
    MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
    SEGMENT SPACE MANAGEMENT AUTO;

PROMPT --> Creando Tablespace BOD_INDX_H_1 en &pathIndx

CREATE TABLESPACE BOD_INDX_H_1
    LOGGING
    DATAFILE '&pathIndx/bod_indx_h_1.dbf' SIZE 2500M
    AUTOEXTEND ON NEXT  200M
    MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
    SEGMENT SPACE MANAGEMENT AUTO;

PROMPT --> Creando Tablespace BOD_INDX_H_10 en &pathIndx

CREATE TABLESPACE BOD_INDX_H_10
    LOGGING
    DATAFILE '&pathIndx/bod_indx_h_10.dbf' SIZE 2500M
    AUTOEXTEND ON NEXT  200M
    MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 10M
    SEGMENT SPACE MANAGEMENT AUTO;

PROMPT --> Creando Tablespace BOD_TEMP en &pathData

CREATE TEMPORARY TABLESPACE BOD_TEMP TEMPFILE
    '&pathData/bod_temp.dbf' SIZE 100M
    AUTOEXTEND ON NEXT 50M
    MAXSIZE UNLIMITED
    TABLESPACE GROUP ''
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 50M;

PROMPT --> Creando Tablespace BOD_USER en &pathData

CREATE TABLESPACE BOD_USER
    LOGGING
    DATAFILE '&pathData/bod_user.dbf' SIZE 200M
    AUTOEXTEND ON NEXT  50M
    MAXSIZE UNLIMITED
    EXTENT MANAGEMENT LOCAL AUTOALLOCATE
    SEGMENT SPACE MANAGEMENT  AUTO;

PROMPT --> Creando Tablespace BOD_UNDO en &pathData

CREATE UNDO TABLESPACE BOD_UNDO
  DATAFILE '&pathData/bod_undo.dbf' SIZE 2000M
  AUTOEXTEND ON NEXT 100M
  MAXSIZE UNLIMITED
  RETENTION GUARANTEE;

CREATE PROFILE LINEG LIMIT
  SESSIONS_PER_USER UNLIMITED
  CPU_PER_SESSION UNLIMITED
  CPU_PER_CALL UNLIMITED
  CONNECT_TIME UNLIMITED
  IDLE_TIME UNLIMITED
  LOGICAL_READS_PER_SESSION UNLIMITED
  LOGICAL_READS_PER_CALL UNLIMITED
  COMPOSITE_LIMIT UNLIMITED
  PRIVATE_SGA UNLIMITED
  FAILED_LOGIN_ATTEMPTS 10
  PASSWORD_LIFE_TIME UNLIMITED
  PASSWORD_REUSE_TIME UNLIMITED
  PASSWORD_REUSE_MAX UNLIMITED
  PASSWORD_LOCK_TIME 1
  PASSWORD_GRACE_TIME 7
  PASSWORD_VERIFY_FUNCTION NULL;



PROMPT --> Privilegios usuario Bodega

  GRANT CONNECT TO BODEGA WITH ADMIN OPTION;
  GRANT DBA TO BODEGA;

  GRANT CREATE LIBRARY TO BODEGA;
  GRANT EXECUTE ANY PROCEDURE TO BODEGA;
  GRANT ALTER DATABASE TO BODEGA;
  GRANT DROP PUBLIC DATABASE LINK TO BODEGA;
  GRANT DROP ANY SYNONYM TO BODEGA;
  GRANT DROP ANY CLUSTER TO BODEGA;
  GRANT ALTER ANY TABLE TO BODEGA;
  GRANT ALTER ROLLBACK SEGMENT TO BODEGA;
  GRANT DROP TABLESPACE TO BODEGA;
  GRANT ALTER ANY SQL PROFILE TO BODEGA;
  GRANT MANAGE SCHEDULER TO BODEGA;
  GRANT SELECT ANY DICTIONARY TO BODEGA;
  GRANT DROP ANY DIMENSION TO BODEGA;
  GRANT EXECUTE ANY INDEXTYPE TO BODEGA;
  GRANT EXECUTE ANY OPERATOR TO BODEGA;
  GRANT ALTER ANY TYPE TO BODEGA;
  GRANT CREATE TYPE TO BODEGA;
  GRANT CREATE ANY MATERIALIZED VIEW TO BODEGA;
  GRANT ALTER ANY TRIGGER TO BODEGA;
  GRANT SELECT ANY SEQUENCE TO BODEGA;
  GRANT CREATE ANY SYNONYM TO BODEGA;
  GRANT CREATE ANY TABLE TO BODEGA;
  GRANT MANAGE ANY FILE GROUP TO BODEGA;
  GRANT DEBUG ANY PROCEDURE TO BODEGA;
  GRANT CREATE ANY DIMENSION TO BODEGA;
  GRANT CREATE OPERATOR TO BODEGA;
  GRANT DROP ANY LIBRARY TO BODEGA;
  GRANT CREATE ANY TYPE TO BODEGA;
  GRANT DROP ANY PROCEDURE TO BODEGA;
  GRANT ALTER ANY PROCEDURE TO BODEGA;
  GRANT DROP ANY SEQUENCE TO BODEGA;
  GRANT CREATE ANY SEQUENCE TO BODEGA;
  GRANT INSERT ANY TABLE TO BODEGA;
  GRANT SELECT ANY TABLE TO BODEGA;
  GRANT CREATE ROLLBACK SEGMENT TO BODEGA;
  GRANT ALTER SESSION TO BODEGA;
  GRANT ALTER SYSTEM TO BODEGA;
  GRANT READ ANY FILE GROUP TO BODEGA;
  GRANT DROP ANY SQL PROFILE TO BODEGA;
  GRANT FLASHBACK ANY TABLE TO BODEGA;
  GRANT DROP ANY OUTLINE TO BODEGA;
  GRANT UNDER ANY TABLE TO BODEGA;
  GRANT UNDER ANY TYPE TO BODEGA;
  GRANT CREATE ANY DIRECTORY TO BODEGA;
  GRANT DROP ANY MATERIALIZED VIEW TO BODEGA;
  GRANT ALTER ANY MATERIALIZED VIEW TO BODEGA;
  GRANT CREATE PROFILE TO BODEGA;
  GRANT DROP ANY TRIGGER TO BODEGA;
  GRANT FORCE ANY TRANSACTION TO BODEGA;
  GRANT CREATE ROLE TO BODEGA;
  GRANT ALTER ANY SEQUENCE TO BODEGA;
  GRANT DROP ANY VIEW TO BODEGA;
  GRANT CREATE SYNONYM TO BODEGA;
  GRANT ALTER ANY INDEX TO BODEGA;
  GRANT CREATE ANY INDEX TO BODEGA;
  GRANT CREATE CLUSTER TO BODEGA;
  GRANT DROP USER TO BODEGA;

  GRANT MANAGE TABLESPACE TO BODEGA;
  GRANT CREATE SESSION TO BODEGA;
  GRANT CREATE EXTERNAL JOB TO BODEGA;
  GRANT CHANGE NOTIFICATION TO BODEGA;
  GRANT SELECT ANY TRANSACTION TO BODEGA;
  GRANT CREATE JOB TO BODEGA;
  GRANT ADVISOR TO BODEGA;
  GRANT DEBUG CONNECT SESSION TO BODEGA;
  GRANT ON COMMIT REFRESH TO BODEGA;
  GRANT CREATE DIMENSION TO BODEGA;
  GRANT QUERY REWRITE TO BODEGA;
  GRANT DROP ANY TYPE TO BODEGA;
  GRANT ANALYZE ANY TO BODEGA;
  GRANT ALTER RESOURCE COST TO BODEGA;
  GRANT ALTER PROFILE TO BODEGA;
  GRANT CREATE TRIGGER TO BODEGA;
  GRANT DROP ANY ROLE TO BODEGA;
  GRANT DELETE ANY TABLE TO BODEGA;
  GRANT UNLIMITED TABLESPACE TO BODEGA WITH ADMIN OPTION;
  GRANT CREATE TABLESPACE TO BODEGA;
  GRANT ADMINISTER SQL TUNING SET TO BODEGA;
  GRANT CREATE ANY JOB TO BODEGA;
  GRANT IMPORT FULL DATABASE TO BODEGA;
  GRANT GLOBAL QUERY REWRITE TO BODEGA;
  GRANT CREATE ANY INDEXTYPE TO BODEGA;
  GRANT CREATE INDEXTYPE TO BODEGA;
  GRANT EXECUTE ANY LIBRARY TO BODEGA;
  GRANT ALTER ANY LIBRARY TO BODEGA;
  GRANT CREATE ANY LIBRARY TO BODEGA;
  GRANT GRANT ANY PRIVILEGE TO BODEGA;
  GRANT DROP PROFILE TO BODEGA;
  GRANT CREATE ANY TRIGGER TO BODEGA;
  GRANT CREATE ANY PROCEDURE TO BODEGA;
  GRANT FORCE TRANSACTION TO BODEGA;
  GRANT AUDIT ANY TO BODEGA;
  GRANT GRANT ANY ROLE TO BODEGA;
  GRANT CREATE SEQUENCE TO BODEGA;
  GRANT DROP PUBLIC SYNONYM TO BODEGA;
  GRANT UPDATE ANY TABLE TO BODEGA;
  GRANT COMMENT ANY TABLE TO BODEGA;
  GRANT DROP ROLLBACK SEGMENT TO BODEGA;
  GRANT RESTRICTED SESSION TO BODEGA;
  GRANT MANAGE FILE GROUP TO BODEGA;
  GRANT EXECUTE ANY CLASS TO BODEGA;
  GRANT GRANT ANY OBJECT PRIVILEGE TO BODEGA;
  GRANT MERGE ANY VIEW TO BODEGA;
  GRANT ADMINISTER DATABASE TRIGGER TO BODEGA;
  GRANT DROP ANY CONTEXT TO BODEGA;
  GRANT CREATE ANY CONTEXT TO BODEGA;
  GRANT UNDER ANY VIEW TO BODEGA;
  GRANT ALTER ANY INDEXTYPE TO BODEGA;
  GRANT DROP ANY OPERATOR TO BODEGA;
  GRANT DROP ANY DIRECTORY TO BODEGA;
  GRANT CREATE MATERIALIZED VIEW TO BODEGA;

  GRANT CREATE ANY VIEW TO BODEGA;
  GRANT CREATE PUBLIC SYNONYM TO BODEGA;
  GRANT ALTER ANY CLUSTER TO BODEGA;
  GRANT CREATE ANY CLUSTER TO BODEGA;
  GRANT LOCK ANY TABLE TO BODEGA;
  GRANT BACKUP ANY TABLE TO BODEGA;
  GRANT BECOME USER TO BODEGA;

  GRANT ALTER TABLESPACE TO BODEGA;
  GRANT AUDIT SYSTEM TO BODEGA;
  GRANT CREATE ANY SQL PROFILE TO BODEGA;
  GRANT ADMINISTER ANY SQL TUNING SET TO BODEGA;
  GRANT EXECUTE ANY PROGRAM TO BODEGA;
  GRANT EXPORT FULL DATABASE TO BODEGA;
  GRANT RESUMABLE TO BODEGA;
  GRANT ALTER ANY OUTLINE TO BODEGA;
  GRANT CREATE ANY OUTLINE TO BODEGA;
  GRANT ALTER ANY DIMENSION TO BODEGA;
  GRANT DROP ANY INDEXTYPE TO BODEGA;
  GRANT CREATE ANY OPERATOR TO BODEGA;
  GRANT EXECUTE ANY TYPE TO BODEGA;
  GRANT CREATE PROCEDURE TO BODEGA;
  GRANT ALTER ANY ROLE TO BODEGA;

  GRANT CREATE VIEW TO BODEGA;
  GRANT DROP ANY INDEX TO BODEGA;
  GRANT DROP ANY TABLE TO BODEGA;
  GRANT CREATE TABLE TO BODEGA;
  

--GRANT CONNECT, EXP_FULL_DATABASE, IMP_FULL_DATABASE, UNLIMITED TABLESPACE, DBA TO COPIA;
GRANT EXP_FULL_DATABASE, IMP_FULL_DATABASE, UNLIMITED TABLESPACE, CONNECT, FLASHBACK ANY TABLE TO COPIA;


PROMPT --> Creando Directorio Data_pump

CREATE OR REPLACE DIRECTORY DATA_PUMP_DIR_LINEG AS '/exp/lineg';
GRANT READ, WRITE ON DIRECTORY DATA_PUMP_DIR_LINEG TO COPIA;



ALTER SYSTEM SET OPEN_CURSORS=300 SCOPE=SPFILE;
ALTER SYSTEM SET UNDO_MANAGEMENT=AUTO SCOPE=SPFILE;
ALTER SYSTEM SET UNDO_RETENTION=900 SCOPE=SPFILE;
ALTER SYSTEM SET UNDO_TABLESPACE=BOD_UNDO SCOPE=SPFILE;
ALTER SYSTEM SET PROCESSES=150 SCOPE=SPFILE;
ALTER SYSTEM SET UTL_FILE_DIR=* SCOPE=SPFILE;

PROMPT --> Bajando Instancia 

SHUTDOWN IMMEDIATE;

PROMPT --> Generando archivo Init[Instancia].ora

CREATE PFILE FROM SPFILE;

PROMPT --> Subiendo la Instancia
STARTUP; 
