CREATE TABLE LOGNFCE (
  CDFILIAL         	VARCHAR2(4)   NOT NULL,
  CDCAIXA          	VARCHAR2(3)   NOT NULL,
  NRSEQVENDA       	VARCHAR2(10)  NOT NULL,
  NRSEQLOGNFCE     	VARCHAR2(3)   NULL,
  NRSEQLOGNFCEMSDE 	VARCHAR2(3)   NULL,
  IDSITUVENDA    	VARCHAR2(1)   NULL,
  NRSEQVENDAMSDE 	VARCHAR2(10)  NULL,
  DTABERTUR 		DATE          NULL,
  CDSERIENFCE    	VARCHAR2(3)   NULL,
  NRNOTAFISCALCE 	VARCHAR2(10)  NULL,
  NRACESSONFCE   	VARCHAR2(50)  NULL,
  DSOBSSTATUSNFCE 	VARCHAR2(500) NULL,
  DTEMISSAONFCE   	DATE          NULL,
  IDSTATUSNFCE    	VARCHAR2(1)   NULL,
  NRLANCTONFCE    	VARCHAR2(10)  NULL,
  IDOPERACAO 		VARCHAR2(1) DEFAULT 'U' NOT NULL,
    CONSTRAINT CKC_IDOPERACAO_LOGNFCE CHECK (IDOPERACAO IN ('U', 'I', 'E')),
  DTHRLOGNFCE 		DATE         NULL,
  IDIMPLOGNFCE 		VARCHAR2(1)  DEFAULT 'N' NOT NULL,
    CONSTRAINT CKC_IDIMPLOGNFCE_LOGNFCE CHECK (IDIMPLOGNFCE IN ('S', 'N')),
  DSREMOTEADDR 		VARCHAR2(500)    NULL, 
  DSREMOTEHOST 		VARCHAR2(500)    NULL,
  DSSERVERRDM 		VARCHAR2(500)    NULL, 
  DSSERVMETHOD 		VARCHAR2(500)    NULL, 
  DSREMOTEOPER 		VARCHAR2(500)    NULL,
  NRORG 	       	NUMBER 			 DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') NOT NULL,
  IDATIVO			VARCHAR2(1) 	 DEFAULT 'S' NOT NULL
    CONSTRAINT CKC_IDATIVO_LOGNFCE CHECK (IDATIVO IN ('S', 'N')),          
  DTINCLUSAO      	DATE           	 DEFAULT SYSDATE,
  DTULTATU        	DATE           	 DEFAULT SYSDATE,
  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_LOGNFCE PRIMARY KEY (CDFILIAL,CDCAIXA,NRSEQVENDA,NRSEQLOGNFCE)
)
/
CREATE INDEX VND00834_FK ON LOGNFCE (CDFILIAL ASC, CDCAIXA ASC, NRSEQVENDA ASC)
/

ALTER TABLE LOGNFCE
   ADD CONSTRAINT FKVND00834LOGNFCE FOREIGN KEY (CDFILIAL, CDCAIXA, NRSEQVENDA)
      REFERENCES VENDA (CDFILIAL, CDCAIXA, NRSEQVENDA)

/