--Eseguire come utente DWH

-- creazione tabella per report SLA FRANCHIGIA. --
 
CREATE TABLE MNP_DW_SLA_FRANCHIGIA_OUT
(
  TIPO_EVENTO	            VARCHAR2(4)	  NOT NULL,
  DATA_EVENTO	            DATE	        NOT NULL,
  MESE_COMP_FINALE        VARCHAR2(7)	  NOT NULL,
  DONOR_EFFETTIVO	        VARCHAR2(4)	  NOT NULL,
  RECIPIENT_EFFETTIVO	    VARCHAR2(4)	  NOT NULL,
  DONOR_RETE	            VARCHAR2(4)	  NOT NULL,
  RECIPIENT_RETE	        VARCHAR2(4)	  NOT NULL,
  EVENTI_ATTESI	          NUMBER	  DEFAULT 0    NOT NULL,
  EVENTI_IN_SLA	          NUMBER	  DEFAULT 0    NOT NULL,
  EVENTI_FUORI_SLA	      NUMBER	  DEFAULT 0    NOT NULL,
  PERCENTUALE_FUORI_SLA	  NUMBER	  DEFAULT 0    NOT NULL,
  PROCESSO	             VARCHAR2(1)	  NOT NULL,
  DATA_AGG                DATE
)
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 MNP_DW_SLA_FRANCHIGIA_OUT_PK ON MNP_DW_SLA_FRANCHIGIA_OUT
( TIPO_EVENTO, DATA_EVENTO, DONOR_EFFETTIVO, RECIPIENT_EFFETTIVO, DONOR_RETE)
LOGGING
TABLESPACE TAB_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_FRANCHIGIA_OUT ADD (
  CONSTRAINT MNP_DW_SLA_FRANCHIGIA_OUT_PK
 PRIMARY KEY
 ( TIPO_EVENTO, DATA_EVENTO,DONOR_EFFETTIVO, RECIPIENT_EFFETTIVO, DONOR_RETE)
    USING INDEX 
    TABLESPACE TAB_SMALL
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          10M
                NEXT             10M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
               ));
CREATE INDEX IDX_MNP_DW_SLA_FRANCHIGIA_OUT1 ON MNP_DW_SLA_FRANCHIGIA_OUT
(MESE_COMP_FINALE)
LOGGING
TABLESPACE TAB_IDX_HUGE_2_2
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          512M
            NEXT             10M
            MINEXTENTS       1
            MAXEXTENTS       2147483645
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL
/