CREATE TABLE SERVICOCOMPENSACAO (
  NRSERVCOMPENSACAO NUMBER(10) NOT NULL, 
  NRPARAMCOMPENSACAO NUMBER(10) NOT NULL, 
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDSERVFILI VARCHAR2(5) 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_SERVICOCOMPENSACAO PRIMARY KEY(NRSERVCOMPENSACAO, NRORG)
)
/
ALTER TABLE SERVICOCOMPENSACAO ADD CONSTRAINT FKFAI00622PARAMCOMPENSACAO FOREIGN KEY (NRPARAMCOMPENSACAO, NRORG) REFERENCES PARAMCOMPENSACAO (NRPARAMCOMPENSACAO, NRORG) ON DELETE CASCADE
/
ALTER TABLE SERVICOCOMPENSACAO ADD CONSTRAINT CKC_IDATIVO_SERVICOCOMPENSACAO CHECK (IDATIVO IN ('S','N'))
/
CREATE INDEX SERVICOCOMPENSACAO_01 ON SERVICOCOMPENSACAO (NRPARAMCOMPENSACAO, CDFILIAL, CDSERVFILI)
/
CREATE INDEX FKFAI00622PARAMCOMPENSACAO ON SERVICOCOMPENSACAO (NRPARAMCOMPENSACAO)