ALTER TABLE TRABNECECOMP ADD IDAPROVTRABNECECOMP VARCHAR2(1) 
         CONSTRAINT CKC_IDAPROVTRABNECECOMP CHECK (IDAPROVTRABNECECOMP IS NULL OR (IDAPROVTRABNECECOMP IN ('S', 'N'))) 
/

CREATE TABLE APROVTRABNECECOMP (
    NRAPROVTRABNECECOMP NUMBER 			NOT NULL,
    NRNECECOMP          VARCHAR2(10) 	NOT NULL,
    CDFILIAL            VARCHAR2(4) 	NOT NULL,
    CDPRODNECCMP        VARCHAR2(10) 	NOT NULL,
    CDOPERADORCOMP      VARCHAR2(12) 	NOT NULL,
    CDOPERADOR          VARCHAR2(12) 	NOT NULL,
    DSJUSTNECECOMP      VARCHAR2(1000),
    IDAPROVTRABNECECOMP VARCHAR2(1), 
    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_APROVTRABNECECOMP CHECK (IDATIVO IN ('S','N')),
		CONSTRAINT PK_APROVTRABNECECOMP PRIMARY KEY(NRAPROVTRABNECECOMP),
		CONSTRAINT UN_APROVTRABNECECOMP UNIQUE(NRNECECOMP, CDFILIAL, CDPRODNECCMP, CDOPERADORCOMP),
        CONSTRAINT CKC_APROVTRABNECECOMP CHECK (IDAPROVTRABNECECOMP IS NULL OR (IDAPROVTRABNECECOMP IN ('S', 'N')))
)
/

CREATE SEQUENCE SEQ_APROVTRABNECECOMP INCREMENT BY 1 MINVALUE 1
/