ALTER TABLE NAF47.SSO_ADENDA
 DROP PRIMARY KEY CASCADE;

DROP TABLE NAF47.SSO_ADENDA CASCADE CONSTRAINTS;

CREATE TABLE NAF47.SSO_ADENDA
(
  IDSOLUCION     VARCHAR2(20 BYTE),
  TIPOADENDA     VARCHAR2(25 BYTE),
  ACTIVOSCRM     NUMBER,
  ACTIVOSNAF     NUMBER,
  CODEMPRESA     NUMBER,
  CODCLIENTE     NUMBER,
  INSTALACION    NUMBER,
  TIPOSERVICIO   VARCHAR2(5 BYTE),
  NOTRANSACCION  NUMBER
)
TABLESPACE NAF47
RESULT_CACHE (MODE DEFAULT)
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            MAXSIZE          UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX NAF47.PK_SSO_ADENDA ON NAF47.SSO_ADENDA
(IDSOLUCION, CODEMPRESA, CODCLIENTE, INSTALACION, TIPOSERVICIO, 
NOTRANSACCION)
LOGGING
TABLESPACE NAF47
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            MAXSIZE          UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
            FLASH_CACHE      DEFAULT
            CELL_FLASH_CACHE DEFAULT
           )
NOPARALLEL;


ALTER TABLE NAF47.SSO_ADENDA ADD (
  CONSTRAINT PK_SSO_ADENDA
  PRIMARY KEY
  (IDSOLUCION, CODEMPRESA, CODCLIENTE, INSTALACION, TIPOSERVICIO, NOTRANSACCION)
  USING INDEX NAF47.PK_SSO_ADENDA
  ENABLE VALIDATE);

ALTER TABLE NAF47.SSO_ADENDA ADD (
  CONSTRAINT FK_SSO_ADENDA_1 
  FOREIGN KEY (CODEMPRESA, CODCLIENTE, INSTALACION, TIPOSERVICIO, NOTRANSACCION) 
  REFERENCES NAF47.SSO_FDIN (CODEMPRESA,CODCLIENTE,INSTALACION,TIPOSERVICIO,NOTRANSACCION)
  ENABLE VALIDATE);
