CREATE TABLE ITEMPRECOHIST (
   CDFILIAL       VARCHAR2(4)   NOT NULL,
   CDTABEPREC     VARCHAR2(3)   NOT NULL,
   DTINIVGPREC    DATE          NOT NULL,
   CDPRODUTO      VARCHAR2(10)  NOT NULL,
   NRSEQITPREHIS  VARCHAR2(10)  NOT NULL,
   IDOPEITPREHIS  VARCHAR2(1)   NULL
      CONSTRAINT CKC_IDOPEITPREHIS_ITPREHIS CHECK (IDOPEITPREHIS IN ('I','A','E')),
   DTOPEITPREHIS  DATE          NULL,
   VRPRECITEMNEW  FLOAT         NULL,
   VRPRECITEMOLD  FLOAT         NULL,
   NRORG          NUMBER        DEFAULT SYS_CONTEXT('NRORG_CTX','NRORG') NOT NULL,
   IDATIVO        VARCHAR2(1)   DEFAULT 'S' NOT NULL
      CONSTRAINT CKC_IDATIVO_ITPREHIS 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_ITEMPRECOHIST PRIMARY KEY (CDFILIAL, CDTABEPREC, DTINIVGPREC, CDPRODUTO, NRSEQITPREHIS)
)
/

CREATE INDEX ITEMPRECOHIST_01 ON ITEMPRECOHIST (CDFILIAL ASC, CDTABEPREC ASC, DTINIVGPREC ASC)
/

CREATE INDEX ITEMPRECOHIST_02 ON ITEMPRECOHIST (CDFILIAL ASC, CDTABEPREC ASC, DTINIVGPREC ASC, CDPRODUTO ASC)
/