ALTER TABLE VTE.D_PRD DROP PRIMARY KEY CASCADE;
DROP TABLE VTE.D_PRD CASCADE CONSTRAINTS;

------ Table D_PRD
------
CREATE TABLE VTE.D_PRD
(
  ID_PRD           NUMBER(10)                   NOT NULL,
  NO_VER_T         NUMBER(5)                    NOT NULL,
  DD_VAL_T         DATE                             NULL,
  DF_VAL_T         DATE                             NULL,
  CD_PRD_K         VARCHAR2(6 BYTE)                 NULL,
  CD_GRP_TY_PTE_H  VARCHAR2(4 BYTE)                 NULL,
  IN_ACC_H         VARCHAR2(1 BYTE)                 NULL,
  IN_RED_TV_H      VARCHAR2(1 BYTE)                 NULL,
  UNI_QTE_BAS_H    VARCHAR2(3 BYTE)                 NULL,
  UNI_QTE_VTE_H    VARCHAR2(3 BYTE)                 NULL,
  UNI_QTE_ACH_H    VARCHAR2(3 BYTE)                 NULL,
  UNI_QTE_OUT_H    VARCHAR2(3 BYTE)                 NULL,
  TX_MAR_FOR_H     NUMBER(8,5)                      NULL,
  DT_MDF_T         DATE                             NULL,
  IN_ENR_CUR_T     VARCHAR2(1 BYTE)                 NULL,
  NO_TRT_T         NUMBER(8)                        NULL,
  CL_SIO_T         VARCHAR2(30 BYTE)                NULL,
  TY_ENR_T         VARCHAR2(1 BYTE)                 NULL,
  CD_FLX_SRC_T     VARCHAR2(30 BYTE)                NULL,
  ID_CAT_PRD_H     NUMBER(10)                   NOT NULL,
  ID_PRD_BRD_H     NUMBER(10)                   NOT NULL,
  ID_TY_LIB_PRD_H  NUMBER(10)                   NOT NULL,
  ID_TYP_PRD_H     NUMBER(10)                   NOT NULL,
  ID_SGR_H         NUMBER(10)                   NOT NULL,
  ID_SEG_H         NUMBER(10)                   NOT NULL,
  ID_NAT_PRD_H     NUMBER(10)                   NOT NULL,
  ID_DIR_PRD_H     NUMBER(10)                       NULL,
  IN_GRD_IMP_H     VARCHAR2(1 BYTE)                 NULL,
  CONSTRAINT ID_PRD PRIMARY KEY (ID_PRD)
             USING INDEX  TABLESPACE CNAM_VTE_IDX
             STORAGE ( INITIAL 10M NEXT 10M PCTINCREASE 0 )
)
TABLESPACE CNAM_VTE
STORAGE ( INITIAL 50M   NEXT 10M   MINEXTENTS 5   MAXEXTENTS 10 )
LOGGING
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


---------------------------------------------------
ALTER TABLE VTE.F_LIG_VTE DROP PRIMARY KEY CASCADE;
DROP TABLE VTE.F_LIG_VTE CASCADE CONSTRAINTS;

------ Table F_LIG_VTE
------
CREATE TABLE VTE.F_LIG_VTE ( 
  ID_LIG_VTE              NUMBER (10)   NOT NULL, 
  CD_SIT_CDE_K1           VARCHAR2 (4)  NOT NULL, 
  NO_CDE_K2               VARCHAR2 (7)  NOT NULL, 
  AA_CDE_K3               VARCHAR2 (4)  NOT NULL, 
  NO_LIG_CDE_K4           VARCHAR2 (3)  NOT NULL, 
  DT_COMPTA               DATE          NOT NULL, 
  DT_DELIV                DATE          NOT NULL, 
  DT_LIG_CDE              DATE          NOT NULL, 
  HH_LIG_CDE              VARCHAR2 (8)  NOT NULL, 
  PX_UNIT_HT              NUMBER (12,2) NOT NULL, 
  PX_UNIT_TTC             NUMBER (12,2) NOT NULL, 
  QT_CDE                  NUMBER (12)   NOT NULL, 
  QT_LIVR                 NUMBER (12)   NOT NULL, 
  ID_CLT                  NUMBER (10)   NOT NULL, 
  CD_CLT_GRD_CPTE         VARCHAR2 (10), 
  DT_LIV_PREV             DATE, 
  IN_RPL_CLT              VARCHAR2 (1)  NOT NULL, 
  ID_VDE                  NUMBER (10), 
  MT_BRUT_TTC             NUMBER (12,2) NOT NULL, 
  MT_BRUT_HT              NUMBER (12,2) NOT NULL, 
  TX_TVA                  NUMBER (5,2)  NOT NULL, 
  ID_PRD                  NUMBER (10)   NOT NULL, 
  NO_VER_PRD_CPTA_T       NUMBER (5)    NOT NULL, 
  NO_VER_PRD_T            NUMBER (5)    NOT NULL, 
  ID_TYP_DELIV            NUMBER (10)   NOT NULL, 
  ID_DEV                  NUMBER (10)   NOT NULL, 
  IN_BDL_DET              VARCHAR2 (1)  NOT NULL, 
  IN_BDL_ENT              VARCHAR2 (1)  NOT NULL, 
  ID_MTF_RET              NUMBER (10)   NOT NULL, 
  ID_IND_VTE              NUMBER (10)   NOT NULL, 
  IN_LIG_CND              VARCHAR2 (1)  NOT NULL, 
  CD_USG_TV               VARCHAR2 (2)  NOT NULL, 
  ID_SIT_CDE              NUMBER (10)   NOT NULL, 
  NO_VER_SIT_CDE_CPTA_T   NUMBER (5)    NOT NULL, 
  NO_VER_SIT_CDE_T        NUMBER (5)    NOT NULL, 
  ID_SIT_VTE              NUMBER (10)   NOT NULL, 
  NO_VER_SIT_VTE_CPTA_T   NUMBER (5)    NOT NULL, 
  NO_VER_SIT_VTE_T        NUMBER (5)    NOT NULL, 
  ID_SIT_RESA             NUMBER (10)   NOT NULL, 
  NO_VER_SIT_RESA_CPTA_T  NUMBER (5)    NOT NULL, 
  NO_VER_SIT_RESA_T       NUMBER (5)    NOT NULL, 
  CD_FLX_SRC_T            VARCHAR2 (30)  NOT NULL, 
  CL_SIO_T                VARCHAR2 (30)  NOT NULL, 
  NO_TRT_T                NUMBER (8)    NOT NULL, 
  DT_MDF_T                DATE          NOT NULL, 
  ID_VTE                  NUMBER (10)   NOT NULL,
  CONSTRAINT F_LVTE_ID_LIG_VTE PRIMARY KEY (ID_LIG_VTE)
             USING INDEX  TABLESPACE CNAM_VTE_IDX
             STORAGE ( INITIAL 20M NEXT 10M PCTINCREASE 0 )
)
TABLESPACE CNAM_VTE
STORAGE ( INITIAL 100M   NEXT 50M   MINEXTENTS 5   MAXEXTENTS 10 )
LOGGING
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


-----------------------------------------------
ALTER TABLE VTE.F_VTE DROP PRIMARY KEY CASCADE;
DROP TABLE VTE.F_VTE CASCADE CONSTRAINTS;

------ Table F_VTE
------
CREATE TABLE VTE.F_VTE
(
  ID_VTE            NUMBER(10)                  NOT NULL,
  NO_CDE_K2         VARCHAR2(7 BYTE)            NOT NULL,
  CD_SIT_CDE_K1     VARCHAR2(4 BYTE)            NOT NULL,
  AA_CDE_K3         VARCHAR2(4 BYTE)            NOT NULL,
  ID_CLT            NUMBER(10)                  NOT NULL,
  CD_CLT_GRD_CPTE   VARCHAR2(10 BYTE),
  ID_DEV            NUMBER(10),
  ID_SIT_CDE        NUMBER(10),
  NO_VER_SIT_CDE_T  NUMBER(5),
  CL_SIO_T          VARCHAR2(30 BYTE),
  CD_FLX_SRC_T      VARCHAR2(30 BYTE),
  DT_CDE            DATE,
  IN_CUISINE        VARCHAR2(1 BYTE),
  NO_TRT_T          NUMBER(8),
  DT_MDF_T          DATE,
  CONSTRAINT F_VTE_ID_VTE PRIMARY KEY (ID_VTE)
             USING INDEX  TABLESPACE CNAM_VTE_IDX
             STORAGE ( INITIAL 20M NEXT 10M PCTINCREASE 0 )
)
TABLESPACE CNAM_VTE
STORAGE ( INITIAL 100M   NEXT 50M   MINEXTENTS 5   MAXEXTENTS 10 )
LOGGING
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


