-- MNP_BIT_IN_REC
ALTER TABLE MNP_BIT_IN_REC ADD (ID_RICHIESTA VARCHAR2(23 BYTE));

CREATE INDEX IDX_MNP_BIT_IN_REC_1 ON MNP_BIT_IN_REC (ID_RICHIESTA) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_BIT_PPBU_OUT_REC
CREATE INDEX IDX_MNP_BIT_PPBU_OUT_REC_1 ON MNP_BIT_PPBU_OUT_REC (ID_RICHIESTA_DBC) 
TABLESPACE TAB_IDX_HUGE_2_1;

-- MNP_BIT_SCARTI_IN
CREATE INDEX IDX_MNP_BIT_SCARTI_IN_2 ON MNP_BIT_SCARTI_IN (DATA_INSERIMENTO) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_BIT_TC_DONOR_OUT
CREATE INDEX IDX_MNP_BIT_TC_DONOR_OUT_1 ON MNP_BIT_TC_DONOR_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_BLOCCO_RICHIESTE
CREATE INDEX IDX_MNP_BLOCCO_RICHIESTE_1 ON MNP_BLOCCO_RICHIESTE (ID_RICHIESTA) 
TABLESPACE TAB_MNP_CONSOLE_INDX;

-- MNP_BONIFICHE_DONOR
CREATE INDEX IDX_MNP_BONIFICHE_DONOR_1 ON MNP_BONIFICHE_DONOR (ID_RICHIESTA) 
TABLESPACE TAB_MNP_CONSOLE_INDX;

-- MNP_BONIFICHE_RECIPIENT
CREATE INDEX IDX_MNP_BONIFICHE_RECIPIENT_1 ON MNP_BONIFICHE_RECIPIENT (ID_RICHIESTA) 
TABLESPACE TAB_MNP_CONSOLE_INDX;

-- MNP_CIRCE_OUT_SCARTI
CREATE INDEX IDX_MNP_CIRCE_OUT_SCARTI_1 ON MNP_CIRCE_OUT_SCARTI (DATA_INSERIMENTO) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_DBCFX_DPP_OUT
CREATE INDEX IDX_MNP_DBCFX_DPP_OUT_1 ON MNP_DBCFX_DPP_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_DBCGO_NOT_DON_VIRT_OUT
CREATE INDEX IDX_DBCGO_NOT_DON_VIRT_OUT_1 ON MNP_DBCGO_NOT_DON_VIRT_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_BIG;

-- MNP_DBCGO_NOT_DON_VIRT_TC_OUT
CREATE INDEX IDX_DBCGO_NOT_DON_VIR_TC_OUT_1 ON MNP_DBCGO_NOT_DON_VIRT_TC_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_BIG;

-- MNP_DBCGO_NOT_REC_VIRT_OUT
CREATE INDEX IDX_DBCGO_NOT_REC_VIR_OUT_1 ON MNP_DBCGO_NOT_REC_VIRT_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_BIG;

-- MNP_DBCGO_NOT_REC_VIRT_TC_OUT
CREATE INDEX IDX_DBCGO_NOT_REC_VIR_TC_OUT_1 ON MNP_DBCGO_NOT_REC_VIRT_TC_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_BIG;

-- MNP_FMSRISK_CESSAZIONE_OUT
ALTER TABLE MNP_FMSRISK_CESSAZIONE_OUT ADD (ID_RICHIESTA VARCHAR2(23 BYTE));

CREATE INDEX IDX_MNP_FMSRISK_CESS_OUT_1 ON MNP_FMSRISK_CESSAZIONE_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_GINO_RETRIEVE_OUT
CREATE INDEX IDX_MNP_GINO_RETRIEVE_OUT_1 ON MNP_GINO_RETRIEVE_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_BIG;

-- MNP_GISP_NOTIFICA_IN
CREATE INDEX IDX_MNP_GISP_NOTIFICA_IN_1 ON MNP_GISP_NOTIFICA_IN (ID_RICHIESTA) 
TABLESPACE TAB_IDX_HUGE_2_1;

-- MNP_GISP_SCARTO_ATT_CESS_IN
CREATE INDEX IDX_GISP_SCARTO_ATT_CESS_IN_1 ON MNP_GISP_SCARTO_ATT_CESS_IN (DATA_RICEZIONE) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_GISP_SCARTO_NOTIFICA_IN
CREATE INDEX IDX_GISP_SCARTO_NOTIFICA_IN_1 ON MNP_GISP_SCARTO_NOTIFICA_IN (DATA_RICEZIONE) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_MSC_IN_REC
CREATE INDEX IDX_MNP_MSC_IN_REC_2 ON MNP_MSC_IN_REC (ID_RICHIESTA) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_MSC_OUT_REC
CREATE INDEX IDX_MNP_MSC_OUT_REC_2 ON MNP_MSC_OUT_REC (ID_RICHIESTA) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_MSC_SCARTI_IN
CREATE INDEX IDX_MNP_MSC_SCARTI_IN_1 ON MNP_MSC_SCARTI_IN (DATA_INSERIMENTO) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_MSP_END_TC_OUT
CREATE INDEX IDX_MNP_MSP_END_TC_OUT_1 ON MNP_MSP_END_TC_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_MSP_IN_REC
CREATE INDEX IDX_MNP_MSP_IN_REC_2 ON MNP_MSP_IN_REC (ID_RICHIESTA) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_MSP_OUT_REC
CREATE INDEX IDX_MNP_MSP_OUT_REC_2 ON MNP_MSP_OUT_REC (ID_RICHIESTA) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_MSP_SCARTI_IN
CREATE INDEX IDX_MNP_MSP_SCARTI_IN_1 ON MNP_MSP_SCARTI_IN (DATA_INSERIMENTO) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_MSP_SCARTO_TC_IN
CREATE INDEX IDX_MNP_MSP_SCARTO_TC_IN_1 ON MNP_MSP_SCARTO_TC_IN (DATA_RICEZIONE) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_MSS_SCARTI_IN
CREATE INDEX IDX_MNP_MSS_SCARTI_IN_1 ON MNP_MSS_SCARTI_IN (DATA_INSERIMENTO) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_MVNO_NOTIFICA_DON_OUT
CREATE INDEX IDX_MNP_MVNO_NOTIF_DON_OUT_2 ON MNP_MVNO_NOTIFICA_DON_OUT (ID_RICHIESTA_DBC) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_MVNO_NOTIFICA_REC_OUT
CREATE INDEX IDX_MNP_MVNO_NOTIF_REC_OUT_1 ON MNP_MVNO_NOTIFICA_REC_OUT (ID_RICHIESTA_DBC) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_MVNO_NOT_SLA_DON_OUT
CREATE INDEX IDX_MNP_MVNO_NOT_SLA_DON_OUT_1 ON MNP_MVNO_NOT_SLA_DON_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_MVNO_NOT_SLA_REC_OUT
CREATE INDEX IDX_MNP_MVNO_NOT_SLA_REC_OUT_1 ON MNP_MVNO_NOT_SLA_REC_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_MVNO_PORTING_IN
CREATE INDEX IDX_MNP_MVNO_PORTING_IN_1 ON MNP_MVNO_PORTING_IN (ID_RICHIESTA_DBC) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_MVNO_SCARTO_PORTING_IN
CREATE INDEX IDX_MNP_MVNO_SCARTO_PORT_IN_1 ON MNP_MVNO_SCARTO_PORTING_IN (DATA_RICEZIONE) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_MVNO_SCARTO_TC_IN
CREATE INDEX IDX_MNP_MVNO_SCARTO_TC_IN_1 ON MNP_MVNO_SCARTO_TC_IN (DATA_RICEZIONE) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_MVNO_SCARTO_UPDATE_DCO_IN
CREATE INDEX IDX_MNP_MVNO_SCAR_UPT_DCO_IN_1 ON MNP_MVNO_SCARTO_UPDATE_DCO_IN (DATA_RICEZIONE) 
TABLESPACE TAB_IDX_MEDIUM;

-- MNP_MVNO_SCARTO_VALIDAZ_IN
CREATE INDEX MNP_MVNO_SCAR_VALID_IN_1 ON MNP_MVNO_SCARTO_VALIDAZ_IN (DATA_RICEZIONE) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_MVNO_VALIDAZ_IN
CREATE INDEX IDX_MNP_MVNO_VALIDAZ_IN_1 ON MNP_MVNO_VALIDAZ_IN (ID_RICHIESTA_DBC) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_SBLOCCO_RICHIESTE
CREATE INDEX IDX_MNP_SBLOCCO_RICHIESTE_1 ON MNP_SBLOCCO_RICHIESTE (ID_RICHIESTA) 
TABLESPACE TAB_MNP_CONSOLE_INDX;

-- MNP_SEC_SMS_OUT
CREATE INDEX IDX_MNP_SEC_SMS_OUT_1 ON MNP_SEC_SMS_OUT (ID_RICHIESTA) 
TABLESPACE TAB_IDX_HUGE_2_2;

-- MNP_SMS_L1
CREATE INDEX IDX_MNP_SMS_L1_1 ON MNP_SMS_L1 (ID_RICHIESTA) 
TABLESPACE TAB_MEDIUM;

-- MNP_SMS_L1V
CREATE INDEX IDX_MNP_SMS_L1V_1 ON MNP_SMS_L1V (ID_RICHIESTA) 
TABLESPACE TAB_MEDIUM;

-- MNP_XML_IN_FP
CREATE INDEX IDX_MNP_XML_IN_FP_1 ON MNP_XML_IN_FP (DATA_EFF) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_XML_OUT_FP
CREATE INDEX IDX_MNP_XML_OUT_FP_1 ON MNP_XML_OUT_FP (DATA_INVIO) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_XML_RIPETIZIONI_IN
CREATE INDEX IDX_MNP_XML_RIPETIZIONI_IN_2 ON MNP_XML_RIPETIZIONI_IN (DATA_EFF) 
TABLESPACE TAB_IDX_SMALL;

-- MNP_XML_RIPETIZIONI_OUT
CREATE INDEX IDX_MNP_XML_RIPETIZIONI_OUT_1 ON MNP_XML_RIPETIZIONI_OUT (DATA_EFF) 
TABLESPACE USR;

-- MNP_XML_SCARTO
CREATE INDEX IDX_MNP_XML_SCARTO_1 ON MNP_XML_SCARTO (DATA_EFF) 
TABLESPACE TAB_IDX_SMALL;

CREATE TABLE HIST_GESTIONE_RICHIESTA
(
  ID_RICHIESTA                   VARCHAR2(23)   NOT NULL,
  STATO                          NUMBER(2)      NOT NULL,
  TIPO_CLIENTE                   VARCHAR2(2),
  DATA_CUT_OVER_CALC             DATE           NOT NULL,
  DATA_VALIDAZIONE_MAX           DATE           NOT NULL,
  DA_INVIARE                     NUMBER(1)      NOT NULL,
  COD_CONTROLLO_PRESAINCARICO    NUMBER(2)      NOT NULL,
  CODICE_CONTROLLO_VALIDAZIONE   NUMBER(2),
  DATALAVORAZIONEAOM             DATE,
  DATARICEZIONERICHIESTA         DATE           NOT NULL,
  CODICERIFIUTOVALIDAZIONE       NUMBER(2),
  CODICE_CONTROLLO_ESPLETAMENTO  NUMBER(2)      NOT NULL,
  ORA_CUT_OVER                   VARCHAR2(8)    DEFAULT '14:00:00' NOT NULL,
  TIPO_MESSAGGIO                 NUMBER(1)      NOT NULL,
  CODICE_OPERATORE_RECIPIENT     VARCHAR2(4)    NOT NULL,
  CODICE_OPERATORE_DONATING      VARCHAR2(4)    NOT NULL,
  CODICE_RICHIESTA_RECIPIENT     VARCHAR2(18)   NOT NULL,
  CODICE_GRUPPO                  VARCHAR2(12),
  MSISDN                         VARCHAR2(15)   NOT NULL,
  ADDIZIONALE_1                  VARCHAR2(15),
  ADDIZIONALE_2                  VARCHAR2(15),
  CODICE_FISCALE_PARTITA_IVA     VARCHAR2(16),
  CODICE_PRE_POST_PAGATO         VARCHAR2(3),
  CODICE_ANALOGICO_DIGITALE      VARCHAR2(1),
  DATA_CUT_OVER                  DATE,
  NOME_CLIENTE                   VARCHAR2(30),
  COGNOME_CLIENTE                VARCHAR2(50),
  RAGIONE_SOCIALE                VARCHAR2(80),
  TIPO_DOCUMENTO                 VARCHAR2(3),
  NUMERO_DOCUMENTO               VARCHAR2(30),
  IMSI                           VARCHAR2(15),
  ICCD_SERIAL_NUMBER             VARCHAR2(30),
  NOME_OT                        VARCHAR2(5),
  DATA_VALIDAZIONE_EFF           DATE,
  ABBONATO_PREPAGATO             VARCHAR2(50),
  SIST_COMP                      VARCHAR2(10),
  RICHIESTAADHOCAOM              VARCHAR2(1),
  RICHIESTAADHOC                 VARCHAR2(1),
  HOC_UPDATES                    NUMBER(5),
  ICCID_RICALCOLATO              VARCHAR2(30),
  DA_NOTIFICARE_A_NPTS           NUMBER(1)      NOT NULL,
  TIPO_PORTING_OUT               NUMBER(1),
  UTENZA_DUAL                    VARCHAR2(15),
  BUSINESS_CONSUMER              NUMBER(1),
  DATA_FINE_PROCESSO             DATE,
  MARCAGGIO                      VARCHAR2(2),
  IPOTESI_RIFIUTO                NUMBER(2)      DEFAULT 0,
  PRIORITY                       NUMBER(1),
  SOTTOMARCAGGIO                 VARCHAR2(1),
  BUSINESS_ID                    VARCHAR2(36),
  PROFILO_UTENZA                 VARCHAR2(20),
  FLAG_TC                        VARCHAR2(1)    NOT NULL,
  FLAG_ESP                       NUMBER(1)      NOT NULL,
  CODICE_OPERATORE_DON_EFF       VARCHAR2(4)    NOT NULL,
  CODICE_OPERATORE_REC_EFF       VARCHAR2(4)    NOT NULL,
  PREVALIDAZIONE                 VARCHAR2(100),
  FLAG_PREVALIDAZIONE            VARCHAR2(1)    NOT NULL,
  FLAG_FURTO                     VARCHAR2(1)    NOT NULL,
  CESSATOGG                      VARCHAR2(1)    NOT NULL,
  USAGE                          VARCHAR2(20),
  MAIN_MSISDN                    VARCHAR2(20),
  NOME_SERVIZIO                  VARCHAR2(20),
  ADDITIONAL                     VARCHAR2(20),
  CESSAZIONE_RETE                VARCHAR2(10),
  VERSION                        NUMBER,
  ROUTING_NUMBER                 VARCHAR2(3),
  CODICE_RIFIUTO_VALIDAZIONE     VARCHAR2(100),
  CARATTERIZZAZIONE              VARCHAR2(3),
  DATA_CUT_OVER_EFF              DATE,
  SIMULATO                       VARCHAR2(1)    DEFAULT 'N' NOT NULL
)
TABLESPACE TAB_MEDIUM -- LASCIARE LO STESSO TS O METTERNE UNO NUOVO PER LO STORICO?
PARTITION BY RANGE (DATARICEZIONERICHIESTA) 
(  
  PARTITION HIST_GESTIONE_RICHIESTA1 VALUES LESS THAN (TO_DATE(' 2003-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM, -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA2 VALUES LESS THAN (TO_DATE(' 2003-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA3 VALUES LESS THAN (TO_DATE(' 2004-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA4 VALUES LESS THAN (TO_DATE(' 2004-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA5 VALUES LESS THAN (TO_DATE(' 2005-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA6 VALUES LESS THAN (TO_DATE(' 2005-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA7 VALUES LESS THAN (TO_DATE(' 2006-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA8 VALUES LESS THAN (TO_DATE(' 2006-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA9 VALUES LESS THAN (TO_DATE(' 2007-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA10 VALUES LESS THAN (TO_DATE(' 2007-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA11 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA12 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA13 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA14 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA15 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA16 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA17 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA18 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA19 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA20 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE TS
  PARTITION HIST_GESTIONE_RICHIESTA21 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,
  PARTITION HIST_GESTIONE_RICHIESTA_MAX VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG -- DEFINIRE TS
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;
--
--

CREATE UNIQUE INDEX PK_HIST_GESTIONE_RICHIESTA ON HIST_GESTIONE_RICHIESTA
(ID_RICHIESTA)
TABLESPACE TAB_IDX_BIG -- DEFINIRE TS
NOPARALLEL;

ALTER TABLE HIST_GESTIONE_RICHIESTA ADD (
  CONSTRAINT PK_HIST_GESTIONE_RICHIESTA
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);

CREATE INDEX IDX_HIST_GESTIRICHIESTA_MSISDN ON
HIST_GESTIONE_RICHIESTA (MSISDN)
TABLESPACE TAB_IDX_MEDIUM 
LOCAL;

CREATE INDEX IDX_HISTGESTIRICH_DATRICRICH ON
HIST_GESTIONE_RICHIESTA (DATARICEZIONERICHIESTA)
TABLESPACE TAB_IDX_MEDIUM 
LOCAL;

CREATE INDEX IDX_HISTGESTIRICH_DATACUTOVER ON
HIST_GESTIONE_RICHIESTA (DATA_CUT_OVER)
TABLESPACE TAB_IDX_MEDIUM 
LOCAL;


--
--


CREATE TABLE HIST_GESTIONE_RICHIESTA_REC
(
  ID_RICHIESTA                VARCHAR2(23)      NOT NULL,
  STATO                       NUMBER(2)         NOT NULL,
  TIPO_CLIENTE                VARCHAR2(2)       NOT NULL,
  DATA_CUT_OVER_CALC          DATE              NOT NULL,
  DATA_VALIDAZIONE_MAX        DATE,
  DA_INVIARE                  NUMBER(1)         DEFAULT -1 NOT NULL,
  DATARICEZIONERICHIESTA      DATE              NOT NULL,
  CODICE_OPERATORE_RECIPIENT  VARCHAR2(4)       NOT NULL,
  CODICE_OPERATORE_DONATING   VARCHAR2(4)       NOT NULL,
  CODICE_GRUPPO               VARCHAR2(12),
  MSISDN                      VARCHAR2(15)      NOT NULL,
  ADDIZIONALE_1               VARCHAR2(15),
  ADDIZIONALE_2               VARCHAR2(15),
  CODICE_FISCALE_PARTITA_IVA  VARCHAR2(16),
  CODICE_PRE_POST_PAGATO      VARCHAR2(3),
  CODICE_ANALOGICO_DIGITALE   VARCHAR2(1)       NOT NULL,
  DATA_CUT_OVER               DATE,
  ORA_CUT_OVER                VARCHAR2(8)       DEFAULT '14:00:00' NOT NULL,
  NOME_CLIENTE                VARCHAR2(30),
  COGNOME_CLIENTE             VARCHAR2(50),
  RAGIONE_SOCIALE             VARCHAR2(80),
  TIPO_DOCUMENTO              VARCHAR2(3),
  NUMERO_DOCUMENTO            VARCHAR2(30),
  IMSI                        VARCHAR2(15)      NOT NULL,
  ICCID_SERIAL_NUMBER         VARCHAR2(30),
  NOME_OT                     VARCHAR2(2),
  DA_NOTIFICARE_BIT           NUMBER(1)         DEFAULT -1 NOT NULL,
  DA_NOTIFICARE_NPTS          NUMBER(1)         DEFAULT -1 NOT NULL,
  DA_NOTIFICARE_AOM           VARCHAR2(10),
  CODICE_RICHIESTA_BIT        VARCHAR2(18),
  IS_PRESAINCARICO            NUMBER(1)         DEFAULT 0 NOT NULL,
  ESPLETAMENTODONATING        NUMBER(1)         DEFAULT 0 NOT NULL,
  ESPLETAMENTOTERZEPARTI      VARCHAR2(10),
  ESPLETAMENTOMSS             NUMBER(1)         DEFAULT 0 NOT NULL,
  CODICERIFIUTOVALIDAZIONE    NUMBER(2),
  DATA_VALIDAZIONE_EFF        DATE,
  DATA_CUT_OVER_AOM           DATE,
  IDREQ_INFOBUS               VARCHAR2(24),
  MSISDN_TIM                  VARCHAR2(16),
  NUMERO_INVII                NUMBER(3)         DEFAULT 0 NOT NULL,
  CAUSALE_ACCODAMENTO         VARCHAR2(100),
  RICHIESTAADHOC              NUMBER(1)         DEFAULT 0 NOT NULL,
  RICHIESTAADHOCAOM           NUMBER(1)         DEFAULT 0 NOT NULL,
  HOC_UPDATES                 NUMBER(5)         DEFAULT 0,
  DATA_FINE_PROCESSO          DATE,
  PRIORITY                    NUMBER(1)         DEFAULT 0,
  SISTEMA_MITTENTE            VARCHAR2(10),
  TIPO_SERVIZIO_SISTEMA_MITT  VARCHAR2(10),
  BUSINESS_ID                 VARCHAR2(36),
  PROFILO_RETE                VARCHAR2(4),
  FLAG_TC                     VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  FLAG_ESP                    NUMBER(1)         DEFAULT 0 NOT NULL,
  CODICE_OPERATORE_DON_EFF    VARCHAR2(4)       NOT NULL,
  CODICE_OPERATORE_REC_EFF    VARCHAR2(4)       NOT NULL,
  ID_CONTRATTO                VARCHAR2(18),
  FLAG_FURTO                  VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  FLAG_PREVALIDAZIONE         VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  MSISDN_PARLI_SUBITO         VARCHAR2(13),
  ROUTING_NUMBER              VARCHAR2(3)       DEFAULT '362',
  CODICE_RIFIUTO_VALIDAZIONE  VARCHAR2(100)     DEFAULT NULL,
  DATA_CUT_OVER_EFF           DATE
)
TABLESPACE USR -- DEFINIRE IL TS
PARTITION BY RANGE (DATARICEZIONERICHIESTA) 
(  
  PARTITION HIST_GESTIONE_RICHIESTA_REC1 VALUES LESS THAN (TO_DATE(' 2003-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC2 VALUES LESS THAN (TO_DATE(' 2003-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC3 VALUES LESS THAN (TO_DATE(' 2004-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC4 VALUES LESS THAN (TO_DATE(' 2004-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC5 VALUES LESS THAN (TO_DATE(' 2005-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC6 VALUES LESS THAN (TO_DATE(' 2005-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC7 VALUES LESS THAN (TO_DATE(' 2006-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC8 VALUES LESS THAN (TO_DATE(' 2006-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC9 VALUES LESS THAN (TO_DATE(' 2007-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC10 VALUES LESS THAN (TO_DATE(' 2007-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC11 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC12 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC13 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC14 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC15 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC16 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC17 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC18 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC19 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC20 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  -- DEFINIRE IL TS
  PARTITION HIST_GESTIONE_RICHIESTA_REC21 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,
  PARTITION HIST_GESTIONE_RICHIESTA_RMAX VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM -- DEFINIRE IL TS
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;
--
--

CREATE UNIQUE INDEX PK_HIST_GESTIONE_RICHIESTA_REC ON HIST_GESTIONE_RICHIESTA_REC
(ID_RICHIESTA)
TABLESPACE TAB_IDX_MEDIUM -- DEFINIRE IL TS
NOPARALLEL;

--

ALTER TABLE HIST_GESTIONE_RICHIESTA_REC ADD (
  CONSTRAINT PK_HIST_GESTIONE_RICHIESTA_REC
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_MEDIUM);

CREATE INDEX IDX_HIST_GESTRICHREC_MSISDN ON
HIST_GESTIONE_RICHIESTA_REC (MSISDN)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;

CREATE INDEX IDX_HISTGESTRICHRECDATARICRICH ON
HIST_GESTIONE_RICHIESTA_REC (DATARICEZIONERICHIESTA)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;

CREATE INDEX IDX_HISTGESTRICHRECDATACUTOVER ON
HIST_GESTIONE_RICHIESTA_REC (DATA_CUT_OVER)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;


--
--

CREATE TABLE HIST_GEST_RICH_DONOR_VIRT
(
  ID_RICHIESTA                VARCHAR2(18)      NOT NULL,
  STATO                       NUMBER(2)         NOT NULL,
  TIPO_CLIENTE                VARCHAR2(2)       NOT NULL,
  DATA_CUT_OVER_CALC          DATE              NOT NULL,
  DATA_VALIDAZIONE_MAX        DATE,
  DATARICEZIONERICHIESTA      DATE              NOT NULL,
  CODICE_OPERATORE_RECIPIENT  VARCHAR2(4)       NOT NULL,
  CODICE_OPERATORE_DONATING   VARCHAR2(4)       NOT NULL,
  CODICE_GRUPPO               VARCHAR2(12),
  MSISDN                      VARCHAR2(15)      NOT NULL,
  CODICE_FISCALE_PARTITA_IVA  VARCHAR2(16),
  CODICE_PRE_POST_PAGATO      VARCHAR2(3)       NOT NULL,
  CODICE_ANALOGICO_DIGITALE   VARCHAR2(1)       NOT NULL,
  DATA_CUT_OVER               DATE,
  ORA_CUT_OVER                VARCHAR2(8)       DEFAULT '14:00:00' NOT NULL,
  NOME_CLIENTE                VARCHAR2(30),
  COGNOME_CLIENTE             VARCHAR2(50),
  RAGIONE_SOCIALE             VARCHAR2(80),
  TIPO_DOCUMENTO              VARCHAR2(3),
  NUMERO_DOCUMENTO            VARCHAR2(30),
  IMSI                        VARCHAR2(15)      NOT NULL,
  ICCID_SERIAL_NUMBER         VARCHAR2(30),
  NOME_OT                     VARCHAR2(2),
  CODICE_RICHIESTA_BIT        VARCHAR2(18),
  CODICERIFIUTOVALIDAZIONE    NUMBER(2),
  DATA_VALIDAZIONE_EFF        DATE,
  MSISDN_TIM                  VARCHAR2(16),
  CAUSALE_ACCODAMENTO         VARCHAR2(100),
  SISTEMA_MITTENTE            VARCHAR2(10),
  TIPO_SERVIZIO_SISTEMA_MITT  VARCHAR2(10),
  BUSINESS_ID                 VARCHAR2(36),
  IPOTESI_RIFIUTO             NUMBER(2)         DEFAULT 0,
  CODICE_DEALER               VARCHAR2(10),
  COD_PROFILO_TARIFFARIO      VARCHAR2(10),
  DESC_PROFILO_TARIFFARIO     VARCHAR2(50),
  COD_OFFERTA                 VARCHAR2(5),
  DESC_OFFERTA                VARCHAR2(50),
  COD_ACCORDO                 VARCHAR2(10),
  DESC_ACCORDO                VARCHAR2(150),
  DESCANALE_VENDITA           VARCHAR2(50),
  CODICE_ORDINE               VARCHAR2(15),
  TIPO_OPERAZIONE             VARCHAR2(3),
  IDREQ_INFOBUS               VARCHAR2(24),
  VERSION                     NUMBER,
  FLAG_TC                     VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  FLAG_ESP                    NUMBER(1)         DEFAULT 0 NOT NULL,
  ID_CONTRATTO                VARCHAR2(18),
  FLAG_FURTO                  VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  FLAG_PREVALIDAZIONE         VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  RICHIESTAADHOC              NUMBER(1)         DEFAULT 0 NOT NULL,
  PREVALIDAZIONE              VARCHAR2(100),
  MSISDN_PARLI_SUBITO         VARCHAR2(13),
  CARATTERIZZAZIONE           NUMBER(1)         DEFAULT -1 NOT NULL,
  ICCID_RICALCOLATO           VARCHAR2(30),
  CESSATOGG                   VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  CODICE_RIFIUTO_VALIDAZIONE  VARCHAR2(100)     DEFAULT NULL,
  DATA_CUT_OVER_EFF           DATE,
  DA_NOTIFICARE_AOM           VARCHAR2(10),
  DA_NOTIFICARE_NPTS          NUMBER(1)         NOT NULL,
  ESPLETAMENTODONATING        NUMBER(1)         NOT NULL,
  ESPLETAMENTOTERZEPARTI      VARCHAR2(10),
  ACK_PORTING                 VARCHAR2(10),
  DATA_PRESA_IN_CARICO        DATE,
  DATA_ACQUISIZIONE           DATE
)
TABLESPACE TAB_HUGE -- DEFINIRE TS
PARTITION BY RANGE (DATARICEZIONERICHIESTA) 
(  
  PARTITION HIST_GEST_RICH_DONOR_VIRT1 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT2 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT3 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT4 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT5 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT6 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT7 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT8 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT9 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT10 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT11 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DONOR_VIRT_MAX VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE -- DEFINIRE IL TS
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

--

CREATE UNIQUE INDEX PK_HIST_GEST_RICH_DONOR_VIRT ON HIST_GEST_RICH_DONOR_VIRT
(ID_RICHIESTA)
LOGGING
TABLESPACE TAB_IDX_BIG -- DEFINIRE TS
NOPARALLEL;


ALTER TABLE HIST_GEST_RICH_DONOR_VIRT ADD (
  CONSTRAINT PK_HIST_GEST_RICH_DONOR_VIRT
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);

CREATE INDEX IDX_HISTGESTRICHDONVIRTMSISDN ON
HIST_GEST_RICH_DONOR_VIRT (MSISDN)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;

CREATE INDEX IDX_HGESTRICHDONVIRDATRICRICH ON
HIST_GEST_RICH_DONOR_VIRT (DATARICEZIONERICHIESTA)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;

CREATE INDEX IDX_HGESTRICHDONVIRDATCUTOV ON
HIST_GEST_RICH_DONOR_VIRT (DATA_CUT_OVER)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;
--
--

CREATE TABLE HIST_GEST_RICH_DON_TC
(
  ID_RICHIESTA                   VARCHAR2(23)   NOT NULL,
  STATO                          NUMBER(2)      NOT NULL,
  DATARICEZIONERICHIESTA         DATE           NOT NULL,
  CREDITO                        NUMBER(7,2)    NOT NULL,
  DATA_NOTIFICA_RECIPIENT        DATE,
  FLAG_VERIFICA_CREDITO_ANOMALO  NUMBER(1)      DEFAULT 0,
  DA_INVIARE                     NUMBER(1)      NOT NULL,
  IDREQ_INFOBUS                  VARCHAR2(24),
  VERSION                        NUMBER
)
TABLESPACE USR -- DEFINIRE IL TS
PARTITION BY RANGE (DATARICEZIONERICHIESTA) 
(  
  PARTITION HIST_GEST_RICH_DON_TC1 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC2 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC3 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC4 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC5 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC6 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC7 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC8 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC9 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_TC_MAX VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG -- DEFINIRE IL TS
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX PK_HIST_GEST_RICH_DON_TC ON HIST_GEST_RICH_DON_TC
(ID_RICHIESTA)
LOGGING
TABLESPACE TAB_IDX_BIG
NOPARALLEL;

ALTER TABLE HIST_GEST_RICH_DON_TC ADD (
  CONSTRAINT PK_HIST_GEST_RICH_DON_TC
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);
--
--

CREATE TABLE HIST_GEST_RICH_DON_VIRT_TC
(
  ID_RICHIESTA             VARCHAR2(23)    NOT NULL,
  STATO                    NUMBER(2)       NOT NULL,
  DATARICEZIONERICHIESTA   DATE            NOT NULL,
  CREDITO                  NUMBER(7,2)     NOT NULL,
  DATA_NOTIFICA_RECIPIENT  DATE,
  IDREQ_INFOBUS            VARCHAR2(24),
  VERSION                  NUMBER
)
TABLESPACE TAB_BIG -- DEFINIRE IL TS
PARTITION BY RANGE (DATARICEZIONERICHIESTA) 
(  
  PARTITION HIST_GEST_RICH_DON_VIRT_TC1 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TC2 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TC3 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TC4 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TC5 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TC6 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TC7 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TC8 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TC9 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_DON_VIRT_TCMAX VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG -- DEFINIRE IL TS
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;


CREATE UNIQUE INDEX PK_HIST_GEST_RICH_DON_VIRT_TC ON HIST_GEST_RICH_DON_VIRT_TC
(ID_RICHIESTA)
LOGGING
TABLESPACE TAB_IDX_BIG
NOPARALLEL;

ALTER TABLE HIST_GEST_RICH_DON_VIRT_TC ADD (
  CONSTRAINT PK_HIST_GEST_RICH_DON_VIRT_TC
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);
--
--


CREATE TABLE HIST_GEST_RICH_REC_TC
(
  ID_RICHIESTA                   VARCHAR2(23)   NOT NULL,
  STATO                          NUMBER(2)      NOT NULL,
  DATARICEZIONERICHIESTA         DATE           NOT NULL,
  CREDITO                        NUMBER(7,2)    NOT NULL,
  DATA_NOTIFICA_RECIPIENT        DATE,
  FLAG_VERIFICA_CREDITO_ANOMALO  NUMBER(1)      DEFAULT 0,
  VERSION                        NUMBER,
  DATA_ACK_TC                    DATE
)
TABLESPACE USR -- DEFINIRE IL TS
PARTITION BY RANGE (DATARICEZIONERICHIESTA) 
(  
  PARTITION HIST_GEST_RICH_REC_TC1 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TC2 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TC3 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TC4 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TC5 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TC6 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TC7 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TC8 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TC9 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_TCMAX VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG -- DEFINIRE IL TS
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;


CREATE UNIQUE INDEX PK_HIST_GEST_RICH_REC_TC ON HIST_GEST_RICH_REC_TC
(ID_RICHIESTA)
LOGGING
TABLESPACE TAB_IDX_BIG
NOPARALLEL;

ALTER TABLE HIST_GEST_RICH_REC_TC ADD (
  CONSTRAINT PK_HIST_GEST_RICH_REC_TC
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);
--
--


CREATE TABLE HIST_GEST_RICH_REC_VIRT
(
  ID_RICHIESTA                VARCHAR2(23)      NOT NULL,
  STATO                       NUMBER(2)         NOT NULL,
  TIPO_CLIENTE                VARCHAR2(2),
  DATA_CUT_OVER_CALC          DATE              NOT NULL,
  DATA_VALIDAZIONE_MAX        DATE              NOT NULL,
  DATARICEZIONERICHIESTA      DATE              NOT NULL,
  CODICERIFIUTOVALIDAZIONE    NUMBER(2),
  DATA_CUT_OVER               DATE,
  ORA_CUT_OVER                VARCHAR2(8)       DEFAULT '14:00:00' NOT NULL,
  CODICE_OPERATORE_RECIPIENT  VARCHAR2(4)       NOT NULL,
  CODICE_OPERATORE_DONATING   VARCHAR2(4)       NOT NULL,
  MSISDN                      VARCHAR2(15)      NOT NULL,
  CODICE_FISCALE_PARTITA_IVA  VARCHAR2(16),
  CODICE_PRE_POST_PAGATO      VARCHAR2(3),
  NOME_CLIENTE                VARCHAR2(30),
  COGNOME_CLIENTE             VARCHAR2(50),
  RAGIONE_SOCIALE             VARCHAR2(80),
  TIPO_DOCUMENTO              VARCHAR2(3),
  NUMERO_DOCUMENTO            VARCHAR2(30),
  IMSI                        VARCHAR2(15),
  ICCID_SERIAL_NUMBER         VARCHAR2(30),
  NOME_OT                     VARCHAR2(5)       DEFAULT NULL,
  DATA_VALIDAZIONE_EFF        DATE,
  ABBONATO_PREPAGATO          VARCHAR2(50),
  SIST_COMP                   VARCHAR2(5),
  ICCID_RICALCOLATO           VARCHAR2(30),
  TIPO_PORTING_OUT            NUMBER(1),
  UTENZA_DUAL                 VARCHAR2(15),
  BUSINESS_CONSUMER           NUMBER(1)         DEFAULT 0,
  MARCAGGIO                   VARCHAR2(2),
  IPOTESI_RIFIUTO             NUMBER(2)         DEFAULT 0,
  SOTTOMARCAGGIO              VARCHAR2(1),
  BUSINESS_ID_RECIPIENT       VARCHAR2(36),
  PROFILO_RETE                VARCHAR2(4)       NOT NULL,
  CODICE_ANALOGICO_DIGITALE   VARCHAR2(1)       NOT NULL,
  VERSION                     NUMBER,
  PROFILO_UTENZA              VARCHAR2(20),
  BUSINESS_ID_DONATING        VARCHAR2(36),
  CODICE_DEALER               VARCHAR2(10),
  IDREQ_INFOBUS               VARCHAR2(24),
  FLAG_TC                     VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  FLAG_ESP                    NUMBER(1)         DEFAULT 0 NOT NULL,
  PREVALIDAZIONE              VARCHAR2(100),
  CARATTERIZZAZIONE           NUMBER(1)         DEFAULT -1 NOT NULL,
  ROUTING_NUMBER              VARCHAR2(3)       DEFAULT '362',
  FLAG_FURTO                  VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  FLAG_PREVALIDAZIONE         VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  RICHIESTAADHOC              NUMBER(1)         DEFAULT 0 NOT NULL,
  CODICE_GRUPPO               VARCHAR2(12),
  CESSATOGG                   VARCHAR2(1)       NOT NULL,
  USAGE                       VARCHAR2(20),
  MAIN_MSISDN                 VARCHAR2(20),
  NOME_SERVIZIO               VARCHAR2(20),
  ADDITIONAL                  VARCHAR2(20),
  CODICE_RIFIUTO_VALIDAZIONE  VARCHAR2(100)     DEFAULT NULL,
  DATA_CUT_OVER_EFF           DATE,
  DA_NOTIFICARE_AOM           VARCHAR2(10),
  DA_NOTIFICARE_NPTS          NUMBER(1)         NOT NULL,
  ESPLETAMENTODONATING        NUMBER(1)         NOT NULL,
  ESPLETAMENTOTERZEPARTI      VARCHAR2(10),
  ACK_PORTING                 VARCHAR2(10),
  SIMULATO                    VARCHAR2(1)       DEFAULT 'N' NOT NULL,
  DATA_PRESA_IN_CARICO        DATE,
  DATA_ACQUISIZIONE           DATE
)
TABLESPACE TAB_HUGE -- DEFINIRE IL TS
PARTITION BY RANGE (DATARICEZIONERICHIESTA) 
(  
  PARTITION HIST_GEST_RICH_REC_VIRT1 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT2 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT3 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT4 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT5 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT6 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT7 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT8 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT9 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT10 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT11 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT5_MAX VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE -- DEFINIRE IL TS
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX PK_HIST_GEST_RICH_REC_VIRT ON HIST_GEST_RICH_REC_VIRT
(ID_RICHIESTA)
LOGGING
TABLESPACE TAB_IDX_BIG
NOPARALLEL;


ALTER TABLE HIST_GEST_RICH_REC_VIRT ADD (
  CONSTRAINT PK_HIST_GEST_RICH_REC_VIRT
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);

CREATE INDEX IDX_HISTGESTRICHRECVIRT_MSISDN ON
HIST_GEST_RICH_REC_VIRT (MSISDN)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;

CREATE INDEX IDX_HISTGESTRICHRECVIRT_DRR ON
HIST_GEST_RICH_REC_VIRT (DATARICEZIONERICHIESTA)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;

CREATE INDEX IDX_HISTGESTRICHRECVIRT_DCO ON
HIST_GEST_RICH_REC_VIRT (DATA_CUT_OVER)
TABLESPACE TAB_IDX_MEDIUM
LOCAL;

--
--


CREATE TABLE HIST_GEST_RICH_REC_VIRT_TC
(
  ID_RICHIESTA                   VARCHAR2(23)   NOT NULL,
  STATO                          NUMBER(2)      NOT NULL,
  DATARICEZIONERICHIESTA         DATE           NOT NULL,
  CREDITO                        NUMBER(7,2)    NOT NULL,
  DATA_NOTIFICA_RECIPIENT        DATE,
  FLAG_VERIFICA_CREDITO_ANOMALO  NUMBER(1)      DEFAULT 0,
  IDREQ_INFOBUS                  VARCHAR2(24),
  VERSION                        NUMBER
)
TABLESPACE USR -- DEFINIRE IL TS
PARTITION BY RANGE (DATARICEZIONERICHIESTA) 
(  
  PARTITION HIST_GEST_RICH_REC_VIRT_TC1 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TC2 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TC3 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TC4 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TC5 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TC6 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TC7 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TC8 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TC9 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG,  -- DEFINIRE IL TS
  PARTITION HIST_GEST_RICH_REC_VIRT_TCMAX VALUES LESS THAN (MAXVALUE)
    NOLOGGING
    NOCOMPRESS
    TABLESPACE TAB_BIG -- DEFINIRE IL TS
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;


CREATE UNIQUE INDEX PK_HIST_GEST_RICH_REC_VIRT_TC ON HIST_GEST_RICH_REC_VIRT_TC
(ID_RICHIESTA)
LOGGING
TABLESPACE TAB_IDX_BIG
NOPARALLEL;


ALTER TABLE HIST_GEST_RICH_REC_VIRT_TC ADD (
  CONSTRAINT PK_HIST_GEST_RICH_REC_VIRT_TC
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);
--
--

CREATE TABLE HIST_GESTIONE_RICHIESTAPORTING
(
  ID_RICHIESTA                   VARCHAR2(23)   NOT NULL,
  STATO                          NUMBER(2)      NOT NULL,
  DA_INVIARE                     NUMBER(1)      DEFAULT 1           NOT NULL,
  DATARICEZIONERICHIESTA         DATE           DEFAULT SYSDATE     NOT NULL,
  CODICE_CONTROLLO_ESPLETAMENTO  NUMBER(2),
  ORA_CUT_OVER                   VARCHAR2(8)    DEFAULT '14:00:00'  NOT NULL,
  TIPO_MESSAGGIO                 NUMBER(1)      NOT NULL,
  CODICE_OPERATORE_RECIPIENT     VARCHAR2(4)    NOT NULL,
  CODICE_OPERATORE_DONATING      VARCHAR2(4)    NOT NULL,
  CODICE_RICHIESTA_RECIPIENT     VARCHAR2(18)   NOT NULL,
  MSISDN                         VARCHAR2(15)   NOT NULL,
  ADDIZIONALE_1                  VARCHAR2(15),
  ADDIZIONALE_2                  VARCHAR2(15),
  DATA_CUT_OVER                  DATE           NOT NULL,
  DA_PROCESSARE                  NUMBER(1)      DEFAULT 1           NOT NULL,
  DATA_FINE_PROCESSO             DATE,
  FLAG_TC                        VARCHAR2(1)    DEFAULT 'N'         NOT NULL,
  CODICE_OPERATORE_DON_EFF       VARCHAR2(4)    NOT NULL,
  CODICE_OPERATORE_REC_EFF       VARCHAR2(4)    NOT NULL,
  ROUTING_NUMBER                 VARCHAR2(3)
)
TABLESPACE TAB_BIG
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX PK_HIST_GEST_RICHIESTAPORTING ON HIST_GESTIONE_RICHIESTAPORTING
(ID_RICHIESTA)
NOLOGGING
TABLESPACE TAB_IDX_MEDIUM
NOPARALLEL;

ALTER TABLE HIST_GESTIONE_RICHIESTAPORTING ADD (
  CONSTRAINT PK_HIST_GEST_RICHIESTAPORTING
 PRIMARY KEY
 (ID_RICHIESTA)
    USING INDEX 
    TABLESPACE TAB_IDX_MEDIUM);

CREATE INDEX IDX_HIST_GESTRICHPORT_MSISDN ON
HIST_GESTIONE_RICHIESTAPORTING (MSISDN)
TABLESPACE TAB_IDX_MEDIUM;

CREATE INDEX IDX_HIST_GESTRICHPORT_DRR ON
HIST_GESTIONE_RICHIESTAPORTING (DATARICEZIONERICHIESTA)
TABLESPACE TAB_IDX_MEDIUM;

CREATE INDEX IDX_HIST_GESTRICHPORT_DCO ON
HIST_GESTIONE_RICHIESTAPORTING (DATA_CUT_OVER)
TABLESPACE TAB_IDX_MEDIUM;
--
--



CREATE TABLE HIST_XML_ACK_IN
(
  TIPO_MESSAGGIO      NUMBER(1)                 NOT NULL,
  RISULTATO           VARCHAR2(5 BYTE)          NOT NULL,
  ERR_MSG             VARCHAR2(128 BYTE),
  NOME_FILE           VARCHAR2(27 BYTE)         NOT NULL,
  ACK                 VARCHAR2(2000 BYTE)       NOT NULL,
  ID_PROG             NUMBER(18)                NOT NULL,
  NOME_FILE_RIFERITO  VARCHAR2(27 BYTE)         NOT NULL,
  DATA_CREAZIONE      DATE                      DEFAULT SYSDATE
)
TABLESPACE TAB_HUGE
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX PK_HIST_XML_ACK_IN ON HIST_XML_ACK_IN
(ID_PROG)
LOGGING
TABLESPACE TAB_IDX_HUGE_2_1
NOPARALLEL;

ALTER TABLE HIST_XML_ACK_IN ADD (
  CONSTRAINT PK_HIST_XML_ACK_IN
 PRIMARY KEY
 (ID_PROG)
    USING INDEX 
    TABLESPACE TAB_IDX_HUGE_2_1);
--
--

CREATE TABLE HIST_XML_ACK_OUT
(
  TIPO_MESSAGGIO      NUMBER(1)                 NOT NULL,
  RISULTATO           VARCHAR2(5 BYTE)          NOT NULL,
  NOME_FILE           VARCHAR2(27 BYTE)         NOT NULL,
  ACK                 VARCHAR2(2000 BYTE)       NOT NULL,
  ID_PROG             NUMBER(18)                NOT NULL,
  ERRMSG              VARCHAR2(2000 BYTE),
  NOME_FILE_RIFERITO  VARCHAR2(27 BYTE)         NOT NULL,
  DATA_INSERIMENTO    DATE                      DEFAULT SYSDATE
)
TABLESPACE TAB_HUGE
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX PK_HIST_XML_ACK_OUT ON HIST_XML_ACK_OUT
(ID_PROG)
LOGGING
TABLESPACE TAB_IDX_HUGE_2_1
NOPARALLEL;

ALTER TABLE HIST_XML_ACK_OUT ADD (
  CONSTRAINT PK_HIST_XML_ACK_OUT
 PRIMARY KEY
 (ID_PROG)
    USING INDEX 
    TABLESPACE TAB_IDX_HUGE_2_1);
--
--

CREATE TABLE HIST_XML_IN
(
  NOME_FILE           VARCHAR2(27 BYTE)         NOT NULL,
  DATA_EFF            DATE                      DEFAULT SYSDATE               NOT NULL,
  ID_FILE             NUMBER(10)                NOT NULL,
  MITTENTE            VARCHAR2(4 BYTE)          NOT NULL,
  DATA                VARCHAR2(10 BYTE)         NOT NULL,
  ORA                 VARCHAR2(8 BYTE)          NOT NULL,
  DESTINATARIO        VARCHAR2(4 BYTE)          NOT NULL,
  TIPO_FILE           VARCHAR2(2 BYTE)          NOT NULL,
  HEADER              VARCHAR2(2000 BYTE)       NOT NULL,
  CANALE_ALTERNATIVO  NUMBER(1)                 DEFAULT 0,
  DA_SCODARE          NUMBER(1)                 DEFAULT 0                     NOT NULL
)
TABLESPACE TAB_HUGE
LOGGING
PARTITION BY RANGE (DATA_EFF) 
(  
  PARTITION HIST_XML_IN1 VALUES LESS THAN (TO_DATE(' 2003-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN2 VALUES LESS THAN (TO_DATE(' 2003-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN3 VALUES LESS THAN (TO_DATE(' 2004-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN4 VALUES LESS THAN (TO_DATE(' 2004-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN5 VALUES LESS THAN (TO_DATE(' 2005-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN6 VALUES LESS THAN (TO_DATE(' 2005-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN7 VALUES LESS THAN (TO_DATE(' 2006-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN8 VALUES LESS THAN (TO_DATE(' 2006-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN9 VALUES LESS THAN (TO_DATE(' 2007-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN10 VALUES LESS THAN (TO_DATE(' 2007-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN11 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN12 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN13 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN14 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN15 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN16 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN17 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN18 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN19 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN20 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN21 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_IN_MAX VALUES LESS THAN (MAXVALUE)
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;


CREATE UNIQUE INDEX PK_HIST_XML_IN ON HIST_XML_IN
(NOME_FILE)
NOLOGGING
TABLESPACE TAB_IDX_BIG
NOPARALLEL;

ALTER TABLE HIST_XML_IN ADD (
  CONSTRAINT PK_HIST_XML_IN
 PRIMARY KEY
 (NOME_FILE)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);
--
--

CREATE TABLE HIST_XML_OUT
(
  NOME_FILE                 VARCHAR2(27 BYTE)   NOT NULL,
  DATA_EFF                  DATE                DEFAULT SYSDATE               NOT NULL,
  ID_FILE                   NUMBER(10)          NOT NULL,
  MITTENTE                  VARCHAR2(4 BYTE)    NOT NULL,
  DATA                      VARCHAR2(10 BYTE)   NOT NULL,
  ORA                       VARCHAR2(8 BYTE)    NOT NULL,
  DESTINATARIO              VARCHAR2(4 BYTE)    NOT NULL,
  TIPO_FILE                 VARCHAR2(2 BYTE)    NOT NULL,
  DA_INVIARE                NUMBER(1)           DEFAULT 1                     NOT NULL,
  HEADER                    VARCHAR2(2000 BYTE) NOT NULL,
  NUMERO_INVII              NUMBER(5)           DEFAULT 0                     NOT NULL,
  DATA_INVIO                DATE,
  TIPO_PROCESSO             VARCHAR2(1 BYTE)    DEFAULT 'D'                   NOT NULL,
  CANALE_ALTERNATIVO        NUMBER(1)           DEFAULT 0,
  NUMERO_INVII_ALTERNATIVO  NUMBER(5)           DEFAULT 0,
  DATA_ULTIMO_INVIO         DATE
)
TABLESPACE TAB_MEDIUM
LOGGING
PARTITION BY RANGE (DATA_EFF) 
(  
  PARTITION HIST_XML_OUT1 VALUES LESS THAN (TO_DATE(' 2003-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT2 VALUES LESS THAN (TO_DATE(' 2003-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT3 VALUES LESS THAN (TO_DATE(' 2004-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT4 VALUES LESS THAN (TO_DATE(' 2004-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT5 VALUES LESS THAN (TO_DATE(' 2005-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT6 VALUES LESS THAN (TO_DATE(' 2005-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT7 VALUES LESS THAN (TO_DATE(' 2006-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT8 VALUES LESS THAN (TO_DATE(' 2006-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT9 VALUES LESS THAN (TO_DATE(' 2007-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT10 VALUES LESS THAN (TO_DATE(' 2007-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT11 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT12 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT13 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT14 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT15 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT16 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT17 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT18 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM, 
  PARTITION HIST_XML_OUT19 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM,  
  PARTITION HIST_XML_OUT20 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM, 
  PARTITION HIST_XML_OUT21 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM, 
  PARTITION HIST_XML_OUT_MAX VALUES LESS THAN (MAXVALUE)
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_MEDIUM
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX PK_HIST_XML_OUT ON HIST_XML_OUT
(NOME_FILE)
LOGGING
TABLESPACE TAB_IDX_BIG
NOPARALLEL;

ALTER TABLE HIST_XML_OUT ADD (
  CONSTRAINT PK_HIST_XML_OUT
 PRIMARY KEY
 (NOME_FILE)
    USING INDEX 
    TABLESPACE TAB_IDX_BIG);
--
--

CREATE TABLE HIST_XML_RICHIESTA_IN
(
  ID_RICHIESTA  VARCHAR2(23 BYTE)               NOT NULL,
  RICHIESTAXML  VARCHAR2(2000 BYTE)             NOT NULL,
  NOME_FILE     VARCHAR2(27 BYTE)               NOT NULL,
  ID_PROG       NUMBER(18)                      NOT NULL,
  DATA_EFF      DATE                            DEFAULT SYSDATE               NOT NULL
)
TABLESPACE TAB_HUGE_2
LOGGING
PARTITION BY RANGE (DATA_EFF) 
(  
  PARTITION HIST_XML_RICHIESTA_IN1 VALUES LESS THAN (TO_DATE(' 2003-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN2 VALUES LESS THAN (TO_DATE(' 2003-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN3 VALUES LESS THAN (TO_DATE(' 2004-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN4 VALUES LESS THAN (TO_DATE(' 2004-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN5 VALUES LESS THAN (TO_DATE(' 2005-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN6 VALUES LESS THAN (TO_DATE(' 2005-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN7 VALUES LESS THAN (TO_DATE(' 2006-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN8 VALUES LESS THAN (TO_DATE(' 2006-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN9 VALUES LESS THAN (TO_DATE(' 2007-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN10 VALUES LESS THAN (TO_DATE(' 2007-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN11 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN12 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN13 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN14 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN15 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN16 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN17 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN18 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN19 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN20 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN21 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_IN_MAX VALUES LESS THAN (MAXVALUE)
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX PK_HIST_XML_RICHIESTA_IN ON HIST_XML_RICHIESTA_IN
(ID_PROG)
NOLOGGING
TABLESPACE TAB_IDX_HUGE_2_1
NOPARALLEL;


ALTER TABLE HIST_XML_RICHIESTA_IN ADD (
  CONSTRAINT PK_HIST_XML_RICHIESTA_IN
 PRIMARY KEY
 (ID_PROG)
    USING INDEX 
    TABLESPACE TAB_IDX_HUGE_2_1);
--
--

CREATE TABLE HIST_XML_RICHIESTA_OUT
(
  ID_RICHIESTA  VARCHAR2(23 BYTE)               NOT NULL,
  RICHIESTAXML  VARCHAR2(2000 BYTE)             NOT NULL,
  NOME_FILE     VARCHAR2(27 BYTE)               NOT NULL,
  ID_PROG       NUMBER(18)                      NOT NULL,
  DATA_EFF      DATE                            DEFAULT SYSDATE               NOT NULL
)
TABLESPACE USR
LOGGING
PARTITION BY RANGE (DATA_EFF) 
(  
  PARTITION HIST_XML_RICHIESTA_OUT1 VALUES LESS THAN (TO_DATE(' 2003-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT2 VALUES LESS THAN (TO_DATE(' 2003-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT3 VALUES LESS THAN (TO_DATE(' 2004-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT4 VALUES LESS THAN (TO_DATE(' 2004-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT5 VALUES LESS THAN (TO_DATE(' 2005-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT6 VALUES LESS THAN (TO_DATE(' 2005-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT7 VALUES LESS THAN (TO_DATE(' 2006-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT8 VALUES LESS THAN (TO_DATE(' 2006-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT9 VALUES LESS THAN (TO_DATE(' 2007-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT10 VALUES LESS THAN (TO_DATE(' 2007-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT11 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT12 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT13 VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT14 VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT15 VALUES LESS THAN (TO_DATE(' 2010-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT16 VALUES LESS THAN (TO_DATE(' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT17 VALUES LESS THAN (TO_DATE(' 2011-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT18 VALUES LESS THAN (TO_DATE(' 2011-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT19 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT20 VALUES LESS THAN (TO_DATE(' 2012-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT21 VALUES LESS THAN (TO_DATE(' 2013-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2,  
  PARTITION HIST_XML_RICHIESTA_OUT_MAX VALUES LESS THAN (MAXVALUE)
    LOGGING
    NOCOMPRESS
    TABLESPACE TAB_HUGE_2
)
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX PK_HIST_XML_RICHIESTA_OUT ON HIST_XML_RICHIESTA_OUT
(ID_PROG)
LOGGING
TABLESPACE TAB_IDX_HUGE_2_1
NOPARALLEL;

ALTER TABLE HIST_XML_RICHIESTA_OUT ADD (
  CONSTRAINT PK_HIST_XML_RICHIESTA_OUT
 PRIMARY KEY
 (ID_PROG)
    USING INDEX 
    TABLESPACE TAB_IDX_HUGE_2_1);

--------------------------------

-- TABELLA DI APPOGGIO PER SALVARE LE RICHIESTE DONOR DA SVECCHIARE
CREATE TABLE HIST_SVECCHIA_DONOR
( ID_RICHIESTA VARCHAR2(23)   NOT NULL )
TABLESPACE TAB_SMALL;

--
-- TABELLA DI APPOGGIO PER SALVARE LE RICHIESTE RECIPIENT DA SVECCHIARE
CREATE TABLE HIST_SVECCHIA_RECIPIENT
( ID_RICHIESTA VARCHAR2(23)   NOT NULL )
TABLESPACE TAB_SMALL;

--
-- TABELLA DI APPOGGIO PER SALVARE LE RICHIESTE DONOR VIRTUALE DA SVECCHIARE
CREATE TABLE HIST_SVECCHIA_DONVIRT
( ID_RICHIESTA VARCHAR2(23)   NOT NULL )
TABLESPACE TAB_SMALL;

--
-- TABELLA DI APPOGGIO PER SALVARE LE RICHIESTE RECIPIENT VIRTUALE DA SVECCHIARE
CREATE TABLE HIST_SVECCHIA_RECVIRT
( ID_RICHIESTA VARCHAR2(23)   NOT NULL )
TABLESPACE TAB_SMALL;

--
-- TABELLA DI APPOGGIO PER SALVARE LE RICHIESTE PORTING DA SVECCHIARE
CREATE TABLE HIST_SVECCHIA_PORTING
( ID_RICHIESTA VARCHAR2(23)   NOT NULL )
TABLESPACE TAB_SMALL;

--
--
CREATE TABLE HIST_GESTIONE_ESECUZIONI
( DATA_STORICIZZAZIONE  DATE,
  DATA_ESECUZIONE       DATE,
  IS_RUNNING            NUMBER)
TABLESPACE TAB_SMALL;
--

create or replace view mnp_richiesta_rec_vgr as
select
    id_richiesta,
    stato,
    tipo_cliente,
    data_cut_over_calc,
    data_validazione_max,
    dataricezionerichiesta,
    codice_operatore_donating,
    codice_gruppo,
    msisdn,
    codice_pre_post_pagato,
    codice_analogico_digitale,
    data_cut_over,
    nome_ot,
    codice_richiesta_bit,
    espletamentodonating,
    espletamentoterzeparti,
    espletamentomss,
    data_validazione_eff,
    data_cut_over_aom,
    idreq_infobus,
    richiestaadhoc,
    richiestaadhocaom,
    hoc_updates
from
MNP_GESTIONE_RICHIESTA_REC;


create or replace view mnp_richiesta_vgr as
select
    id_richiesta,
    stato,
    tipo_cliente,
    data_cut_over_calc,
    data_validazione_max,
    dataricezionerichiesta,
    codice_operatore_recipient,
    codice_operatore_donating,
    codice_gruppo,
    msisdn,
    codice_pre_post_pagato,
    data_cut_over,
    nome_ot,
    data_validazione_eff,
    abbonato_prepagato,
    richiestaadhocaom,
    richiestaadhoc,
    hoc_updates
from MNP_GESTIONE_RICHIESTA;


create or replace view mnp_rich_cess_vgr as
select
id_richiesta,
msisdn,
stato,
dataricezionerichiesta,
codice_operatore_recipient,
data_cut_over
from
MNP_GESTIONE_RICHIESTA_CESS;


create or replace view mnp_rich_cess_port_vgr as
select
id_richiesta,
msisdn,
stato,
dataricezionerichiesta,
data_cut_over
from
MNP_GESTIONE_RICH_CESS_PORT;


create or replace view mnp_rich_porting_vgr as
select
id_richiesta,
stato,
dataricezionerichiesta,
tipo_messaggio,
codice_operatore_recipient,
codice_operatore_donating,
msisdn,
data_cut_over
from
MNP_GESTIONE_RICHIESTA_PORTING;


create or replace view hist_richiesta_rec_vgr as
select
    id_richiesta,
    stato,
    tipo_cliente,
    data_cut_over_calc,
    data_validazione_max,
    dataricezionerichiesta,
    codice_operatore_donating,
    codice_gruppo,
    msisdn,
    codice_pre_post_pagato,
    codice_analogico_digitale,
    data_cut_over,
    nome_ot,
    codice_richiesta_bit,
    espletamentodonating,
    espletamentoterzeparti,
    espletamentomss,
    data_validazione_eff,
    data_cut_over_aom,
    idreq_infobus,
    richiestaadhoc,
    richiestaadhocaom,
    hoc_updates
from
HIST_GESTIONE_RICHIESTA_REC;


create or replace view hist_richiesta_vgr as
select
    id_richiesta,
    stato,
    tipo_cliente,
    data_cut_over_calc,
    data_validazione_max,
    dataricezionerichiesta,
    codice_operatore_recipient,
    codice_operatore_donating,
    codice_gruppo,
    msisdn,
    codice_pre_post_pagato,
    data_cut_over,
    nome_ot,
    data_validazione_eff,
    abbonato_prepagato,
    richiestaadhocaom,
    richiestaadhoc,
    hoc_updates
from HIST_GESTIONE_RICHIESTA;


create or replace view hist_rich_cess_vgr as
select
id_richiesta,
msisdn,
stato,
dataricezionerichiesta,
codice_operatore_recipient,
data_cut_over
from
MNP_GESTIONE_RICHIESTA_CESS;


create or replace view hist_rich_cess_port_vgr as
select
id_richiesta,
msisdn,
stato,
dataricezionerichiesta,
data_cut_over
from
MNP_GESTIONE_RICH_CESS_PORT;


create or replace view hist_rich_porting_vgr as
select
id_richiesta,
stato,
dataricezionerichiesta,
tipo_messaggio,
codice_operatore_recipient,
codice_operatore_donating,
msisdn,
data_cut_over
from
HIST_GESTIONE_RICHIESTAPORTING;


create or replace view mnp_richiesta_rec_vgr_comp as
select *
from mnp_richiesta_rec_vgr
UNION
select *
from 
hist_richiesta_rec_vgr;


create or replace view mnp_richiesta_vgr_comp as
select *
from mnp_richiesta_vgr
UNION
select *
from 
hist_richiesta_vgr;


create or replace view mnp_rich_cess_vgr_comp as
select
id_richiesta,
msisdn,
stato,
dataricezionerichiesta,
codice_operatore_recipient,
data_cut_over
from
MNP_GESTIONE_RICHIESTA_CESS;


create or replace view mnp_rich_cess_port_vgr_comp as
select
id_richiesta,
msisdn,
stato,
dataricezionerichiesta,
data_cut_over
from
MNP_GESTIONE_RICH_CESS_PORT;


create or replace view mnp_rich_porting_vgr_comp as
select *
from mnp_rich_porting_vgr
UNION
select *
from 
hist_rich_porting_vgr;


ALTER TABLE MNP_BIT_ANNULL_OUT RENAME TO BCK_BIT_ANNULL_OUT;
ALTER TABLE MNP_BIT_SCARTI_DONOR RENAME TO BCK_BIT_SCARTI_DONOR;
ALTER TABLE MNP_BIT_SCARTI_UPDATE RENAME TO BCK_BIT_SCARTI_UPDATE;
ALTER TABLE MNP_BIT_UPDATE_DCO RENAME TO BCK_BIT_UPDATE_DCO;
ALTER TABLE MNP_CCRM_APP RENAME TO BCK_CCRM_APP;
ALTER TABLE MNP_CRM_RETENTION_OUT RENAME TO BCK_CRM_RETENTION_OUT;
ALTER TABLE MNP_MSS_APPOGGIO RENAME TO BCK_MSS_APPOGGIO;
ALTER TABLE MNP_MSS_CESS_PORT_ANNULLAMENTI RENAME TO BCK_MSS_CESS_PORT_ANNULLAMENTI;
ALTER TABLE MNP_RICH_DUP_DONOR_REC RENAME TO BCK_RICH_DUP_DONOR_REC;
ALTER TABLE MNP_SCARTI_IN RENAME TO BCK_SCARTI_IN;
ALTER TABLE MNP_SID_IN RENAME TO BCK_SID_IN;
ALTER TABLE MNP_SID_OUT_REC RENAME TO BCK_SID_OUT_REC;
ALTER TABLE MNP_SID_RECIPIENT_RECUPERO_OUT RENAME TO BCK_SID_RECIPIENT_RECUPERO_OUT;
ALTER TABLE MNP_SID_SCARTI_IN RENAME TO BCK_SID_SCARTI_IN;
ALTER TABLE MNP_CRM_VALIDAZIONE_IN RENAME TO BCK_CRM_VALIDAZIONE_IN;
ALTER TABLE MNP_CRM_VALIDAZIONE_OUT RENAME TO BCK_CRM_VALIDAZIONE_OUT;

ALTER TABLE MNP_XML_ACK_IN DROP CONSTRAINT FK_MNP_XML_ACK_IN_1;
ALTER TABLE MNP_XML_ACK_OUT DROP CONSTRAINT FK_MNP_XML_ACK_OUT_1;

ALTER TABLE MNP_XML_ACK_IN ADD CONSTRAINT FK_MNP_XML_ACK_IN_1 FOREIGN KEY (NOME_FILE)
REFERENCES MNP_XML_IN (NOME_FILE) ON DELETE CASCADE;

ALTER TABLE MNP_XML_ACK_OUT ADD CONSTRAINT FK_MNP_XML_ACK_OUT_1 FOREIGN KEY (NOME_FILE)
REFERENCES MNP_XML_OUT (NOME_FILE) ON DELETE CASCADE;
