CREATE TABLE PRODCOMPCOMPL(
    NRPRODCOMPCOMPL   NUMBER NOT NULL,
    CDOPERADOR  	  VARCHAR2(12) NOT NULL,
    CDPRODUTO   	  VARCHAR2(10) NOT NULL,
    CDPRODCOMPL 	  VARCHAR2(10) NOT NULL,
	NRORG             NUMBER 	      DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 		NOT NULL,
    IDATIVO           VARCHAR2(1)     DEFAULT 'S'					NOT NULL,
    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',
		CONSTRAINT CKC_IDATIVO_PRODCOMPCOMPL CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_PRODCOMPCOMPL PRIMARY KEY (NRPRODCOMPCOMPL)
)
/

CREATE SEQUENCE SEQ_NRPRODCOMPCOMPL INCREMENT BY 1 MINVALUE 1
/

ALTER TABLE PRODCOMPCOMPL
   ADD CONSTRAINT FKSUP00689PRODCMPCMPL_OPER FOREIGN KEY (CDOPERADOR)
      REFERENCES OPERADOR (CDOPERADOR)
/
CREATE INDEX SUP00689_FK ON PRODCOMPCOMPL (CDOPERADOR ASC)
/

ALTER TABLE PRODCOMPCOMPL
   ADD CONSTRAINT FKSUP00690PRODCMPCMPL_PROD FOREIGN KEY (CDPRODUTO)
      REFERENCES PRODUTO (CDPRODUTO)
/
CREATE INDEX SUP00690_FK ON PRODCOMPCOMPL (CDPRODUTO ASC)
/
ALTER TABLE PRODCOMPCOMPL
   ADD CONSTRAINT FKSUP00691PRODCMPCMPL_PROD FOREIGN KEY (CDPRODCOMPL)
      REFERENCES PRODUTO (CDPRODUTO)
/
CREATE INDEX SUP00691_FK ON PRODCOMPCOMPL (CDPRODCOMPL ASC)
/

ALTER TABLE PRODCOMPCOMPL ADD CONSTRAINT PRODCOMPCOMPL001 UNIQUE (CDOPERADOR, CDPRODUTO, CDPRODCOMPL)
/

CREATE INDEX PRODCOMPCOMPL_001 ON PRODCOMPCOMPL (CDOPERADOR ASC, CDPRODUTO ASC, CDPRODCOMPL ASC)
/