CREATE TABLE DADOSADIC_APURAC (
  NRDADOSADIC NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  NRAPURACFAT VARCHAR2(10) NOT NULL, 
  CDMENSAGEM VARCHAR2(3) DEFAULT NULL NULL, 
  DSMENSAGEM VARCHAR2(120) NOT NULL, 
  NRORG NUMBER(10) DEFAULT 1 NOT NULL, 
  IDATIVO VARCHAR2(1) DEFAULT 'S' NOT NULL, 
  DTINCLUSAO DATE DEFAULT NULL NULL, 
  DTULTATU DATE DEFAULT NULL NULL, 
  NRORGINCLUSAO NUMBER(10) DEFAULT 1 NULL, 
  CDOPERINCLUSAO VARCHAR2(12) DEFAULT '1' NULL, 
  NRORGULTATU NUMBER(10) DEFAULT 1 NULL, 
  CDOPERULTATU VARCHAR2(12) DEFAULT '1' NULL,
  CONSTRAINT PK_DADOSADIC_APURAC PRIMARY KEY(NRDADOSADIC, NRORG)
)
/
ALTER TABLE DADOSADIC_APURAC ADD CONSTRAINT FKFAI00624CTRLAPURFAT FOREIGN KEY (CDFILIAL, NRAPURACFAT, NRORG) REFERENCES CTRLAPURFAT (CDFILIAL, NRAPURACFAT, NRORG)
/
ALTER TABLE DADOSADIC_APURAC ADD CONSTRAINT CKC_IDATIVO_DADOSADIC_APURAC CHECK (IDATIVO IN ('S','N'))
/
CREATE INDEX FKFAI00624CTRLAPURFAT ON DADOSADIC_APURAC (CDFILIAL, NRAPURACFAT)