CREATE TABLE CLASSECIATIPOPROD (
  CDFILIAL VARCHAR2(4) NOT NULL, 
  CDCIA VARCHAR2(4) NOT NULL, 
  CDCLASSE VARCHAR2(4) NOT NULL, 
  NRTIPOPROD NUMBER(10) 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_CLASSECIATIPOPROD PRIMARY KEY(CDFILIAL, CDCIA, CDCLASSE, NRORG)
)
/
ALTER TABLE CLASSECIATIPOPROD ADD CONSTRAINT FKCOC00680CLASSECIA FOREIGN KEY (CDFILIAL, CDCIA, CDCLASSE, NRORG) REFERENCES CLASSECIA (CDFILIAL, CDCIA, CDCLASSE, NRORG)
/
ALTER TABLE CLASSECIATIPOPROD ADD CONSTRAINT FKCOC00681TIPOPROD FOREIGN KEY (NRTIPOPROD, NRORG) REFERENCES TIPOPROD (NRTIPOPROD, NRORG)
/
ALTER TABLE CLASSECIATIPOPROD ADD CONSTRAINT CKC_IDATIVO_CLASSECIATIPOPROD CHECK (IDATIVO IN ('S','N'))
/
CREATE INDEX FKCOC00681TIPOPROD ON CLASSECIATIPOPROD (NRTIPOPROD, NRORG)