-- ==============================================================================
-- TABLE: PRODUTO
-- ==============================================================================
ALTER TABLE PRODUTO ADD IDTIPOPESO VARCHAR2(2)
/

ALTER TABLE PRODUTO ADD QTPESONOMINAL FLOAT 
/

ALTER TABLE PRODUTO ADD QTPESOMIN FLOAT
/

ALTER TABLE PRODUTO ADD QTPESOMAX FLOAT
/

ALTER TABLE PRODUTO ADD QTVOLPESAGEM FLOAT
/

-- ==============================================================================
-- TABLE: USR_ITEM
-- ==============================================================================
CREATE TABLE USR_ITEM (
   CDEXPORTEMPR         	FLOAT, 
   CDEMPRESA            	VARCHAR2(2), 
   CDFILIAL             		VARCHAR2(4), 
   CDEXFILIAL           	FLOAT, 
   CDPRODINTE           	FLOAT, 
   CDPRODUTO            	VARCHAR2(10), 
   NMPRODUTO            	VARCHAR2(28),
   NMPROD_COMPLETO      	VARCHAR2(50), 
   CDDESTINOFINAL       	FLOAT, 
   IDTIPOPESO           	FLOAT, 
   IDTIPOVALIDADE       	FLOAT, 
   QTDIASVALIDADE       	FLOAT,
   VRTARA               		FLOAT,
   QTPESOMIN            	FLOAT,
   QTPESOMAX           	FLOAT,
   CDEAN13              	FLOAT, 
   CDDUN14              	FLOAT,
   IDPRODATIV 		FLOAT, 
   IDINTEGRACAO         	CHAR(1),
   DTINTEGRACAO         	DATE,
   IDUNIDMEDIMPRES      	FLOAT,
   IDTPSEPARADOR        	FLOAT,
   QTNUMERODEC          	FLOAT, 
   DSFORMATODATA        	VARCHAR2(10), 
   VRREFDIETAKCAL       	FLOAT, 
   DSTELEFONE           	VARCHAR2(20),
   DSFRASEPERIGO        	VARCHAR2(4000),
   DSCOMPOSICAO         	VARCHAR2(4000),
   DSOBSCONSERVACAO     	VARCHAR2(4000),
   CDARVPROD            	VARCHAR2(20),
   DSPREPARACAO         	VARCHAR2(4000),
   QTCALORIAS           	FLOAT, 
   QTCALORIASVXD        	FLOAT, 
   QTCARBOIDRATOS       	FLOAT,
   QTCARBOIDRATOSVXD    	FLOAT, 
   QTPROTEINAS          	FLOAT, 
   QTPROTEINASVXD       	FLOAT, 
   QTGORDTOTAIS         	FLOAT, 
   QTGORDTOTAISVXD      	FLOAT, 
   QTGORDSATURADAS      	FLOAT, 
   QTGORDSATURADASVXD   	FLOAT, 
   QTGORDMONOSAT        	FLOAT, 
   QTGORDMONOSATVXD     	FLOAT, 
   QTGORDURASTRANS      	FLOAT,  
   QTCOLESTEROL         	FLOAT, 
   QTCOLESTEROLVXD      	FLOAT, 
   QTFIBRA              		FLOAT, 
   QTFIBRAVXD           	FLOAT, 
   QTCALCIO             	FLOAT, 
   QTCALCIOVXD          	FLOAT, 
   QTFERRO              	FLOAT, 
   QTFERROVXD           	FLOAT, 
   QTSODIO              	FLOAT, 
   QTSODIOVXD           	FLOAT, 
   QTGORDPOLIINSAT      	FLOAT, 
   QTGORDPOLIINSATVXD   	FLOAT,
   QTPESONOMINAL        	FLOAT,
   NRORG                       	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_USR_ITEM  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'
)
/

-- ==============================================================================
-- TABLE: 	
-- ==============================================================================
CREATE TABLE USR_ORDPRODUCAO (
   CDEXPORTEMPR        	FLOAT, 
   CDEMPRESA            	VARCHAR2(2), 
   CDFILIAL             		VARCHAR2(4), 
   CDEXFILIAL           	FLOAT, 
   CDPRODINTE           	FLOAT, 
   CDPRODUTO            	VARCHAR2(10), 
   NRORDPROD            	VARCHAR2(10),
   NRSUBORDPROD         	VARCHAR2(1),
   DTGERORDPROD         	DATE,
   QTAPRODPREOP         	FLOAT,
   DTPREVISTA           	DATE,
   NRSEQENTRADA         	FLOAT,
   NRSEQSAIDA           	FLOAT,
   IDSITORDPROD         	VARCHAR2(1),
   IDTIPOPLANEJ         	FLOAT,
   NRSEMANA             	FLOAT,
   IDALTERADO           	FLOAT,
   DTINTEGRACAO         	DATE,
   NRLOTEESTQ           	VARCHAR2(20),
   NRSUBLOTE            	VARCHAR2(4),
   NRORG                       	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_USR_ORDPROD  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'
)
/

-- ==============================================================================
-- TABLE: USR_HISTPESOPROD
-- ==============================================================================
CREATE TABLE USR_HISTPESOPROD (
   CDEMPRESA            	VARCHAR2(2), 
   CDFILIAL             		VARCHAR2(4), 
   CDPRODUTO            	VARCHAR2(10),
   NRORDPROD            	VARCHAR2(10),
   NRSUBORDPROD        	VARCHAR2(1),
   NRSEQHIST            	VARCHAR2(3),
   QTEMBALAGEM          	FLOAT,
   QTPESOBRUTO          	FLOAT,
   QTPESOLIQ            	FLOAT,
   VRTARAEXT            	FLOAT,
   VRTARABAL           	FLOAT,
   VRTARAINT            	FLOAT,
   DTFABRICACAO         	DATE,
   DTVALIDADE           	DATE,
   CDSUBPRODETA         	VARCHAR2(10),
   NRSUBPRETAOP         	VARCHAR2(3),
   VRMEDIA              	FLOAT,
   NRPRODACAB           	VARCHAR2(3),
   CDOPERADOR           	VARCHAR2(12),
   DSLOGOPERACAO        	VARCHAR2(300),
   IDINTEGRACAO         	CHAR(1),
   DTINTEGRACAO         	DATE,
   NRORG                       	NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
   IDATIVO                    	VARCHAR2(1)     		DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_USR_HISTPESPR  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'
)