CREATE TABLE RATFISPARTICIP (
  IDTPPART           VARCHAR2(1) DEFAULT 'L' NOT NULL
    CONSTRAINT CKC_IDTPPART_RATFISPARTICIP CHECK (IDTPPART IN ('L','F','C')), --'FILIAL', 'FORNECEDOR' E 'CLIENTE' 
  CDPARTICIPANTE     VARCHAR2(21) NOT NULL,  
  CDRATEIOPADRAO     VARCHAR2(4),
  IDENTRSAIDOP       VARCHAR2(1) DEFAULT 'S' NOT NULL
    CONSTRAINT CKC_IDENTRSAIDOP_RATFISPARTICI CHECK (IDENTRSAIDOP IN ('E', 'S')), --'ENTRADA', 'SAIDA'
  NRORG              NUMBER       DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO            VARCHAR2(1)  DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_RATFISPARTICIP CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO         DATE,
  DTULTATU           DATE,
  NRORGINCLUSAO      NUMBER       DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
  CDOPERINCLUSAO     VARCHAR2(12) DEFAULT '1',
  NRORGULTATU        NUMBER DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg'),
  CDOPERULTATU       VARCHAR2(12),
  CONSTRAINT PK_RATFISPARTICIP PRIMARY KEY (IDTPPART, CDPARTICIPANTE, CDRATEIOPADRAO, IDENTRSAIDOP)
)
/
 
CREATE INDEX FIS00816_FK ON RATFISPARTICIP ( CDRATEIOPADRAO )
/

ALTER TABLE RATFISPARTICIP
   ADD CONSTRAINT FKFIS00816RATEIOPADRAOFIS FOREIGN KEY ( CDRATEIOPADRAO )
      REFERENCES RATEIOPADRAOFIS ( CDRATEIOPADRAO ) ON DELETE CASCADE
/

ALTER TABLE RATEIOPADRAOFIS ADD IDORIGVALOR VARCHAR2(01) DEFAULT 'C' NOT NULL
   CONSTRAINT CKC_IDORIGVALOR_RATEIOPADRAOFI CHECK(IDORIGVALOR IN ('C','B','I'))
/