CREATE TABLE ENTRADAREF
(
    NRSEQUMAPAPU        VARCHAR2(10)            NOT NULL,
	CHAVE               VARCHAR2(14)            NOT NULL,
    CDFILIAL            VARCHAR2(04)            NOT NULL,
    NRLANCTONF          VARCHAR2(10)            NOT NULL, 
    CDPRODUTO           VARCHAR2(10)            NOT NULL,
	CDPRODESTO          VARCHAR2(10)            NOT NULL,
    QTITEMPROD          FLOAT                   NULL, 
	VRFATCONV           FLOAT                   NULL,
    VRCONTITEM          FLOAT                   NULL, 
    VRST                FLOAT                   NULL, 
    CDFILIRECE          VARCHAR2(04)            NULL,
    CDMODDOCFISC        VARCHAR2(02)            NULL, 
    CDSERIEENTR         VARCHAR2(5)             NULL, 
    NRNOTAFISC          VARCHAR2(20)            NULL, 
    DTENTRSAID          DATE                    NULL, 
    CDARVPROD           VARCHAR2(20)            NULL, 
    DTVENDA             DATE                    NOT NULL,
	NRACESSONFE         VARCHAR2(50)            NULL,
	NRORG               NUMBER                 DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
	IDATIVO 			VARCHAR2(1) 	DEFAULT 'S' NOT NULL,
		CONSTRAINT CKC_IDATIVO_ENTRADAREF 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' NULL,
		CONSTRAINT PK_ENTRADAREF PRIMARY KEY (NRSEQUMAPAPU, CHAVE, CDPRODUTO, CDPRODESTO, DTVENDA)
)
/

ALTER TABLE ENTRADAREF ADD CDPRODESTOCOMP VARCHAR2(10) NULL