ALTER TABLE CONSUMIDOR ADD IDANONIMIZADO VARCHAR2(1) DEFAULT 'N' NOT NULL
   CONSTRAINT CKC_IDANONIMIZADO_CONSUMIDOR CHECK (IDANONIMIZADO IN ('S','N')) NOVALIDATE
/

CREATE TABLE ANONIMIZACONS (
   CDCLIENTE      VARCHAR2(21)  NOT NULL,
   CDCONSUMIDOR   VARCHAR2(21)  NOT NULL,
   CDOPERADOR     VARCHAR2(12)  NOT NULL,
   NMOPERADOR     VARCHAR2(40)  NOT NULL,
   DTANONIMIZACAO DATE          NOT NULL,
   NMARQANONIMIZA VARCHAR2(150) NULL,
   DSARQANONIMIZA BLOB          NULL,
   NRORG          NUMBER        DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO        VARCHAR2(1)   DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ANONIMIZACONS CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO     DATE          DEFAULT SYSDATE,
   DTULTATU       DATE          DEFAULT SYSDATE,
   NRORGINCLUSAO  NUMBER        DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERINCLUSAO VARCHAR2(12)  DEFAULT '1' NULL,
   NRORGULTATU    NUMBER        DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NULL,
   CDOPERULTATU   VARCHAR2(12)  DEFAULT '1' NULL,
   CONSTRAINT PK_ANONIMIZACONS PRIMARY KEY (CDCLIENTE, CDCONSUMIDOR)
)
/

CREATE INDEX VND00835_FK ON ANONIMIZACONS (CDCLIENTE ASC, CDCONSUMIDOR ASC)
/

ALTER TABLE ANONIMIZACONS
   ADD CONSTRAINT FKVND00835CONSUMIDOR FOREIGN KEY (CDCLIENTE, CDCONSUMIDOR)
      REFERENCES CONSUMIDOR (CDCLIENTE, CDCONSUMIDOR)
/

CREATE INDEX VND00836_FK ON ANONIMIZACONS (CDOPERADOR ASC)
/

ALTER TABLE ANONIMIZACONS
   ADD CONSTRAINT FKVND00836OPERADOR FOREIGN KEY (CDOPERADOR)
      REFERENCES OPERADOR (CDOPERADOR)
/ 