ALTER TABLE PARAMGERAL ADD IDJUSTALTCOMENS CHAR(1) DEFAULT 'N' NOT NULL
   CONSTRAINT CKC_IDJUSTALTCOMENS CHECK (IDJUSTALTCOMENS IN ('S', 'N'))
/
CREATE TABLE JUSTALTERCOMENS
(
   NRJUSTALTERCOMENS 	NUMBER 		NOT NULL,
   CDFILIAL 		VARCHAR2(4) 	NOT NULL,
   CDSERVFILI 		VARCHAR2(5) 	NOT NULL,
   DTCARDAPIO 		DATE 		NOT NULL,
   QTCOMENSTOTOLD 	FLOAT 		NOT NULL,
   QTCOMENSTOTNEW 	FLOAT 		NOT NULL,
   DTHRALTERCOMENS 	DATE 		NOT NULL,
   CDOPERADOR 		VARCHAR2(12) 	NOT NULL,
   DSJUSTIFICATIVA 		VARCHAR2(200) 	NOT NULL,
   DSACAO 		VARCHAR2(200) 	NULL,
   IDORIGALTERACAO 	VARCHAR2(30) 	NULL
      CONSTRAINT CKK_IDORIGALTERACAO CHECK (IDORIGALTERACAO IS NULL OR IDORIGALTERACAO IN ('EXPORTARCOMENS','AJUSTARECOMENS')),
   NRORG                       	NUMBER 		DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     	DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_JUSTALTERCOMENS CHECK (IDATIVO IN ('S','N')),
   DTINCLUSAO             	DATE                   	NULL,
   DTULTATU                  	DATE                  	NULL,
   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 PK_JUSTALTERCOMENS PRIMARY KEY (NRJUSTALTERCOMENS)
)
/
CREATE INDEX PLA01161_FK ON JUSTALTERCOMENS (CDFILIAL ASC, CDSERVFILI ASC)
/
ALTER TABLE JUSTALTERCOMENS ADD
	CONSTRAINT FKPLA01161_JUSTALTERCOMENS FOREIGN KEY (CDFILIAL, CDSERVFILI)
      		REFERENCES SERVICO (CDFILIAL, CDSERVFILI)