ALTER TABLE COMISSAO ADD DTVALIDADE DATE NULL
/

ALTER TABLE VENDEDOR ADD IDCOMISTABPRECO VARCHAR2(1) DEFAULT 'N' NOT NULL
	CONSTRAINT CKC_IDCOMISTABPR_VEND CHECK (IDCOMISTABPRECO IN ('S', 'N'))
/

CREATE TABLE COMISPREBRASE (
   CDVENDEDOR 		VARCHAR2(4)  		NOT NULL, 
   IDTPIJURVEN 		VARCHAR2(1)  		NOT NULL,  
   NRINSJURVEN		VARCHAR2(20) 		NOT NULL, 
   CDCOMISSAO 		VARCHAR2(10) 		NOT NULL, 
   CDPRECOBASE 		VARCHAR2(2) 		 NOT NULL,
  NRORG          		NUMBER          		DEFAULT 1   	NOT NULL,
  IDATIVO          		VARCHAR2(01)		DEFAULT 'S' 	NOT NULL
      	CONSTRAINT CKC_IDATIVO_COMISPREBRASE  CHECK (IDATIVO IN ('S','N')),
  DTINCLUSAO      	 	DATE           		NULL,
  DTULTATU       		DATE                    		NULL,
  NRORGINCLUSAO   	 	NUMBER         		DEFAULT 1   	NULL,
  CDOPERINCLUSAO  	 	VARCHAR2(12)   		DEFAULT '1' 	NULL,
  NRORGULTATU     	 	NUMBER         		DEFAULT 1   	NULL,
  CDOPERULTATU    		VARCHAR2(12)   		DEFAULT '1'    	NULL,
   CONSTRAINT PK_COMISPREBRASE PRIMARY KEY (CDVENDEDOR, IDTPIJURVEN, NRINSJURVEN, CDCOMISSAO, CDPRECOBASE)
)
/

CREATE INDEX FK_MAN02301 ON COMISPREBRASE (CDVENDEDOR ASC)
/

ALTER TABLE COMISPREBRASE 
    ADD CONSTRAINT FKMAN02301VENDEDOR FOREIGN KEY(CDVENDEDOR)
       REFERENCES VENDEDOR (CDVENDEDOR)
/

CREATE INDEX FK_MAN02302 ON COMISPREBRASE (CDPRECOBASE ASC)
/

ALTER TABLE COMISPREBRASE 
    ADD CONSTRAINT FKMAN02302PRECOBASE FOREIGN KEY(CDPRECOBASE)
       REFERENCES PRECOBASE (CDPRECOBASE)