--Eseguire come utente DWH

-- creazione tabella per report SLA MVNO --
CREATE TABLE MNP_DW_SLA_MVNO_OUT
(
  UNIQUE_ID            NUMBER                NOT NULL,
  MESE                 VARCHAR2(7 BYTE)      NOT NULL,
  DON_OSPITATO         VARCHAR2(4 BYTE)      NOT NULL,
  REC_OSPITATO         VARCHAR2(4 BYTE)      NOT NULL,
  DON_RETE             VARCHAR2(4 BYTE)      NOT NULL,
  REC_RETE             VARCHAR2(4 BYTE)      NOT NULL,
  MSISDN               VARCHAR2(12 BYTE)     NOT NULL,
  ID_RICHIESTA         VARCHAR2(18 BYTE)     NOT NULL,
  TIPO_FILE            VARCHAR2(7 BYTE)      NOT NULL,
  FLAG_VALIDAZIONE     CHAR(1 BYTE)         DEFAULT '1'     NOT NULL,
  FILE_XML             VARCHAR2(27 BYTE)     NOT NULL,
  FILE_ACK             VARCHAR2(27 BYTE)     NOT NULL,
  DATA_AGG             DATE                  DEFAULT sysdate NOT NULL,
  DATA_ESTRAZIONE      DATE                  NULL
)
TABLESPACE TAB_SMALL
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          10M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
NOMONITORING;

CREATE UNIQUE INDEX DWH.MNP_DW_SLA_MVNO_OUT_IDX ON DWH.MNP_DW_SLA_MVNO_OUT
(MESE,ID_RICHIESTA, DON_OSPITATO, REC_OSPITATO, DON_RETE, TIPO_FILE, FLAG_VALIDAZIONE)
LOGGING
NOPARALLEL;


CREATE UNIQUE INDEX MNP_DW_SLA_MVNO_OUT_PK ON MNP_DW_SLA_MVNO_OUT
(UNIQUE_ID)
LOGGING
TABLESPACE TAB_IDX_SMALL
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          10M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;
ALTER TABLE MNP_DW_SLA_MVNO_OUT ADD (
  CONSTRAINT MNP_DW_MVNO_SLA_OUT_PK
 PRIMARY KEY
 (UNIQUE_ID)
    USING INDEX 
    TABLESPACE TAB_IDX_SMALL
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          10M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
Grant select,insert,update,delete on MNP_DW_SLA_MVNO_OUT to MNP;
CREATE SEQUENCE SEQ_DW_SLA_MVNO_OUT
  START WITH 1
  MAXVALUE 999999999999999999999999999
  MINVALUE 1
  NOCYCLE
  CACHE 30
  NOORDER;
