CREATE TABLE USR_RELACLIEOL 
(	
	CDCLIENTE 			VARCHAR2(21)				NOT NULL,
	CDFILIAL  			VARCHAR2(4)					NOT NULL, 
	NRORG               NUMBER          DEFAULT 1 	NOT NULL,
	IDATIVO             VARCHAR2(1)		DEFAULT 'S' NOT NULL
		CONSTRAINT CKC_IDATIVO_USR_RELACLIEOL 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_USR_RELACLIEOL PRIMARY KEY (CDCLIENTE, CDFILIAL)
)
/

ALTER TABLE USR_RELACLIEOL
  ADD CONSTRAINT FKCMP00580CLIENTE FOREIGN KEY (CDCLIENTE)
    REFERENCES CLIENTE (CDCLIENTE) ON DELETE CASCADE
/

CREATE INDEX FKCMP00580CLIENTE ON USR_RELACLIEOL (CDCLIENTE)
/

ALTER TABLE USR_RELACLIEOL
  ADD CONSTRAINT FKCMP00581FILIAL FOREIGN KEY (CDFILIAL)
      REFERENCES FILIAL (CDFILIAL) ON DELETE CASCADE
/

CREATE INDEX FKCMP00581FILIAL ON USR_RELACLIEOL (CDFILIAL)
/
ALTER TABLE PARAMFILIAL ADD USR_IDUTPEDVENDEXT VARCHAR2(1) NULL
/

ALTER TABLE PARAMFILIAL ADD USR_IDUTPEDINTEGRAL VARCHAR2(1) NULL
/

ALTER TABLE PARAMFILIAL ADD USR_VRMINPEDVENDEXT FLOAT NULL
/

ALTER TABLE PARAMFILIAL ADD USR_VRPERCENTVRMIN FLOAT NULL
/

ALTER TABLE PARAMFILIAL ADD USR_CDGROPERAPROV VARCHAR2(2) NULL
/

ALTER TABLE PARAMFILIAL ADD USR_CDGROPAPROVFINANC VARCHAR2(2) NULL
/
ALTER TABLE PEDIDOEXOL ADD USR_IDUTPEDINTEGRAL VARCHAR2(1) NULL
  CONSTRAINT CKC_USR_IDUTPEDINTEGRAL CHECK (USR_IDUTPEDINTEGRAL IN ('S', 'N'))  
/

ALTER TABLE PEDIDOEXOL ADD USR_IDAPROVFINANC VARCHAR2(1) NULL
	CONSTRAINT CKC_USR_IDAPROVFINANC CHECK (USR_IDAPROVFINANC IN ('S', 'N'))
/

ALTER TABLE PEDIDOEXOL ADD USR_IDAPROVALORMIN VARCHAR2(1) NULL
  CONSTRAINT CKC_USR_IDAPROVALORMIN CHECK (USR_IDAPROVALORMIN IN ('S', 'N'))
/

ALTER TABLE PEDIDOEXOL ADD USR_VRAPROVALORMIN FLOAT NULL
/

ALTER TABLE PEDIDOEXOL ADD USR_CDOPERAPROVALORMIN VARCHAR2(12) NULL
/

ALTER TABLE PEDIDOEXOL ADD USR_DTAPROVALORMIN DATE NULL
/

ALTER TABLE PEDIDOEXOL
  ADD CONSTRAINT FKCMP00582OPERADOR FOREIGN KEY (USR_CDOPERAPROVALORMIN)
    REFERENCES OPERADOR (CDOPERADOR)
/

CREATE INDEX FKCMP00582OPERADOR ON PEDIDOEXOL (USR_CDOPERAPROVALORMIN)
/
ALTER TABLE ITEMPEDEXOL ADD USR_QTATENDPEDOLTMP FLOAT NULL
/