--------------------------------------------------------------------------
-- Play this script in PRUEBAS@VISANY to make it look like DESA@VISMAR
--                                                                      --
-- Please review the script before using it to make sure it won't       --
-- cause any unacceptable data loss.                                    --
--                                                                      --
-- PRUEBAS@VISANY Schema Extracted by User PRUEBAS 
-- DESA@VISMAR Schema Extracted by User DESA 
--
-- ESTARTIC  (Table) 
--

CREATE TABLE EST_COMAGENTE
(
  COD_CIA       CHAR(3 BYTE)                    NOT NULL,
  SUCURSAL      CHAR(3 BYTE)                    NOT NULL,
  COD_AGENTE    VARCHAR2(3 BYTE)                NOT NULL,
  ANO_FISCAL    NUMBER(4)                       NOT NULL,
  PER_PROCESO   NUMBER(2)                       NOT NULL,
  COD_COMISION  VARCHAR2(3 BYTE)                NOT NULL,
  MON_COMISION  NUMBER(14,2)                    DEFAULT 0                     NOT NULL
)
LOGGING 
NOCACHE
PARALLEL ( DEGREE DEFAULT INSTANCES 1 )
NOMONITORING;

ALTER TABLE EST_COMAGENTE
 ADD CONSTRAINT EST_COMAGENTE_PK
 PRIMARY KEY
 (COD_CIA, SUCURSAL, COD_AGENTE, ANO_FISCAL, PER_PROCESO, COD_COMISION);

--
-- EST_LINEA_TMP  (Table) 
--
CREATE TABLE EST_LINEA_TMP
(
  COD_CIA        CHAR(3 BYTE)                   NOT NULL,
  SUCURSAL       CHAR(3 BYTE)                   NOT NULL,
  COD_AGENTE     VARCHAR2(3 BYTE)               NOT NULL,
  COD_LINEA      VARCHAR2(5 BYTE)               NOT NULL,
  ANO_FISCAL     NUMBER(4)                      NOT NULL,
  PER_PROCESO    NUMBER(2)                      NOT NULL,
  COD_MONEDA     VARCHAR2(3 BYTE)               NOT NULL,
  MON_VENDIDO    NUMBER(14,2)                   NOT NULL,
  CAN_UNIDADES   NUMBER(14,4)                   NOT NULL,
  MON_DEVUELTO   NUMBER(14,2)                   NOT NULL,
  CAN_DEVUELTAS  NUMBER(14,4)                   NOT NULL
)
LOGGING 
NOCACHE
PARALLEL ( DEGREE DEFAULT INSTANCES 1 )
NOMONITORING;

ALTER TABLE EST_LINEA_TMP
 ADD CONSTRAINT CAN_DEVUELTAS_EST_LINE_CHK
 CHECK (             can_devueltas >= 0);

ALTER TABLE EST_LINEA_TMP
 ADD CONSTRAINT MON_DEVUELTO_EST_LINE_CHK
 CHECK (             mon_devuelto >= 0);

ALTER TABLE EST_LINEA_TMP
 ADD CONSTRAINT MON_VENDIDO_EST_LINE_CHK
 CHECK (             mon_vendido >= 0);

ALTER TABLE EST_LINEA_TMP
 ADD CONSTRAINT EST_LINEA_TMP_PK
 PRIMARY KEY
 (COD_CIA, SUCURSAL, COD_AGENTE, COD_LINEA, ANO_FISCAL, PER_PROCESO, COD_MONEDA);

--
-- EST_PROVEEDOR_TMP  (Table) 
--
CREATE TABLE EST_PROVEEDOR_TMP
(
  COD_CIA        CHAR(3 BYTE)                   NOT NULL,
  SUCURSAL       CHAR(3 BYTE)                   NOT NULL,
  COD_AGENTE     VARCHAR2(3 BYTE)               NOT NULL,
  COD_PROVEEDOR  VARCHAR2(25 BYTE)              NOT NULL,
  ANO_FISCAL     NUMBER(4)                      NOT NULL,
  PER_PROCESO    NUMBER(2)                      NOT NULL,
  COD_MONEDA     VARCHAR2(3 BYTE)               NOT NULL,
  MON_VENDIDO    NUMBER(14,2)                   NOT NULL,
  CAN_UNIDADES   NUMBER(14,4)                   NOT NULL,
  MON_DEVUELTO   NUMBER(14,2)                   NOT NULL,
  CAN_DEVUELTAS  NUMBER(14,4)                   NOT NULL
)
LOGGING 
NOCACHE
PARALLEL ( DEGREE DEFAULT INSTANCES 1 )
NOMONITORING;

ALTER TABLE EST_PROVEEDOR_TMP
 ADD CONSTRAINT MON_DEVUELTO_EST_PROV_CHK
 CHECK (             mon_devuelto >= 0);

ALTER TABLE EST_PROVEEDOR_TMP
 ADD CONSTRAINT CAN_DEVUELTAS_EST_PROV_CHK
 CHECK (             can_devueltas >= 0);

ALTER TABLE EST_PROVEEDOR_TMP
 ADD CONSTRAINT MON_VENDIDO_EST_PROV_CHK
 CHECK (             mon_vendido >= 0);

ALTER TABLE EST_PROVEEDOR_TMP
 ADD CONSTRAINT EST_PROVEEDOR_TMP_PK
 PRIMARY KEY
 (COD_CIA, SUCURSAL, COD_AGENTE, COD_PROVEEDOR, ANO_FISCAL, PER_PROCESO, COD_MONEDA);

**BORRADA DE VISMAR
CREATE TABLE ESTARTIC
(
  CODIGO    VARCHAR2(6 BYTE),
  DESCRIP   VARCHAR2(30 BYTE),
  CANTIDAD  NUMBER,
  PESO      NUMBER,
  PRECIO1   NUMBER(5),
  PRECIO2   NUMBER(5),
  FAMILIA   VARCHAR2(3 BYTE),
  CLASE     VARCHAR2(1 BYTE),
  U1        NUMBER,
  C1        NUMBER,
  V1        NUMBER,
  U2        NUMBER,
  C2        NUMBER,
  V2        NUMBER,
  U3        NUMBER,
  C3        NUMBER,
  V3        NUMBER,
  U4        NUMBER,
  C4        NUMBER,
  V4        NUMBER,
  U5        NUMBER,
  C5        NUMBER,
  V5        NUMBER,
  U6        NUMBER,
  C6        NUMBER,
  V6        NUMBER,
  U7        NUMBER,
  C7        NUMBER,
  V7        NUMBER,
  U8        NUMBER,
  C8        NUMBER,
  V8        NUMBER,
  U9        NUMBER,
  C9        NUMBER,
  V9        NUMBER,
  U10       NUMBER,
  C10       NUMBER,
  V10       NUMBER,
  U11       NUMBER,
  C11       NUMBER,
  V11       NUMBER,
  U12       NUMBER,
  C12       NUMBER,
  V12       NUMBER,
  DUPLI     VARCHAR2(1 BYTE),
  S1        NUMBER,
  S2        NUMBER,
  S3        NUMBER,
  S4        NUMBER,
  S5        NUMBER,
  S6        NUMBER,
  S7        NUMBER,
  S8        NUMBER,
  S9        NUMBER,
  S10       NUMBER,
  S11       NUMBER,
  S12       NUMBER,
  P1        NUMBER(5),
  P2        NUMBER(5),
  P3        NUMBER(5),
  P4        NUMBER(5),
  P5        NUMBER(5),
  P6        NUMBER(5),
  P7        NUMBER(5),
  P8        NUMBER(5),
  P9        NUMBER(5),
  P10       NUMBER(5),
  P11       NUMBER(5),
  P12       NUMBER(5),
  CP1       NUMBER,
  CP2       NUMBER,
  CP3       NUMBER,
  CP4       NUMBER,
  CP5       NUMBER,
  CP6       NUMBER,
  CP7       NUMBER,
  CP8       NUMBER,
  CP9       NUMBER,
  CP10      NUMBER,
  CP11      NUMBER,
  CP12      NUMBER,
  I1        NUMBER,
  I2        NUMBER,
  I3        NUMBER,
  I4        NUMBER,
  I5        NUMBER,
  I6        NUMBER,
  I7        NUMBER,
  I8        NUMBER,
  I9        NUMBER,
  I10       NUMBER,
  I11       NUMBER,
  I12       NUMBER,
  CI1       NUMBER,
  CI2       NUMBER,
  CI3       NUMBER,
  CI4       NUMBER,
  CI5       NUMBER,
  CI6       NUMBER,
  CI7       NUMBER,
  CI8       NUMBER,
  CI9       NUMBER,
  CI10      NUMBER,
  CI11      NUMBER,
  CI12      NUMBER,
  PROMOC    VARCHAR2(1 BYTE),
  DIV       NUMBER
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

--
-- ESTFAMILIA  (Table) 
--
**BORRADA DE VISMAR
CREATE TABLE ESTFAMILIA
(
  CODIGO    VARCHAR2(6 BYTE),
  DESCRIP   VARCHAR2(30 BYTE),
  CANTIDAD  NUMBER,
  PESO      NUMBER,
  PRECIO1   NUMBER(5),
  PRECIO2   NUMBER(5),
  FAMILIA   VARCHAR2(3 BYTE),
  CLASE     VARCHAR2(1 BYTE),
  U1        NUMBER,
  C1        NUMBER,
  V1        NUMBER,
  U2        NUMBER,
  C2        NUMBER,
  V2        NUMBER,
  U3        NUMBER,
  C3        NUMBER,
  V3        NUMBER,
  U4        NUMBER,
  C4        NUMBER,
  V4        NUMBER,
  U5        NUMBER,
  C5        NUMBER,
  V5        NUMBER,
  U6        NUMBER,
  C6        NUMBER,
  V6        NUMBER,
  U7        NUMBER,
  C7        NUMBER,
  V7        NUMBER,
  U8        NUMBER,
  C8        NUMBER,
  V8        NUMBER,
  U9        NUMBER,
  C9        NUMBER,
  V9        NUMBER,
  U10       NUMBER,
  C10       NUMBER,
  V10       NUMBER,
  U11       NUMBER,
  C11       NUMBER,
  V11       NUMBER,
  U12       NUMBER,
  C12       NUMBER,
  V12       NUMBER,
  DUPLI     VARCHAR2(1 BYTE),
  S1        NUMBER,
  S2        NUMBER,
  S3        NUMBER,
  S4        NUMBER,
  S5        NUMBER,
  S6        NUMBER,
  S7        NUMBER,
  S8        NUMBER,
  S9        NUMBER,
  S10       NUMBER,
  S11       NUMBER,
  S12       NUMBER,
  P1        NUMBER(5),
  P2        NUMBER(5),
  P3        NUMBER(5),
  P4        NUMBER(5),
  P5        NUMBER(5),
  P6        NUMBER(5),
  P7        NUMBER(5),
  P8        NUMBER(5),
  P9        NUMBER(5),
  P10       NUMBER(5),
  P11       NUMBER(5),
  P12       NUMBER(5),
  CP1       NUMBER,
  CP2       NUMBER,
  CP3       NUMBER,
  CP4       NUMBER,
  CP5       NUMBER,
  CP6       NUMBER,
  CP7       NUMBER,
  CP8       NUMBER,
  CP9       NUMBER,
  CP10      NUMBER,
  CP11      NUMBER,
  CP12      NUMBER,
  I1        NUMBER,
  I2        NUMBER,
  I3        NUMBER,
  I4        NUMBER,
  I5        NUMBER,
  I6        NUMBER,
  I7        NUMBER,
  I8        NUMBER,
  I9        NUMBER,
  I10       NUMBER,
  I11       NUMBER,
  I12       NUMBER,
  CI1       NUMBER,
  CI2       NUMBER,
  CI3       NUMBER,
  CI4       NUMBER,
  CI5       NUMBER,
  CI6       NUMBER,
  CI7       NUMBER,
  CI8       NUMBER,
  CI9       NUMBER,
  CI10      NUMBER,
  CI11      NUMBER,
  CI12      NUMBER,
  PROMOC    VARCHAR2(1 BYTE),
  DIV       NUMBER
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

--
-- ESTINVEN  (Table) 
--
**BORRADA DE VISMAR
CREATE TABLE ESTINVEN
(
  CODIGO    VARCHAR2(6 BYTE),
  DESCRIP   VARCHAR2(30 BYTE),
  CANTIDAD  NUMBER,
  PESO      NUMBER,
  PRECIO1   NUMBER(5),
  PRECIO2   NUMBER(5),
  FAMILIA   VARCHAR2(3 BYTE),
  CLASE     VARCHAR2(1 BYTE),
  U1        NUMBER,
  C1        NUMBER,
  V1        NUMBER,
  U2        NUMBER,
  C2        NUMBER,
  V2        NUMBER,
  U3        NUMBER,
  C3        NUMBER,
  V3        NUMBER,
  U4        NUMBER,
  C4        NUMBER,
  V4        NUMBER,
  U5        NUMBER,
  C5        NUMBER,
  V5        NUMBER,
  U6        NUMBER,
  C6        NUMBER,
  V6        NUMBER,
  U7        NUMBER,
  C7        NUMBER,
  V7        NUMBER,
  U8        NUMBER,
  C8        NUMBER,
  V8        NUMBER,
  U9        NUMBER,
  C9        NUMBER,
  V9        NUMBER,
  U10       NUMBER,
  C10       NUMBER,
  V10       NUMBER,
  U11       NUMBER,
  C11       NUMBER,
  V11       NUMBER,
  U12       NUMBER,
  C12       NUMBER,
  V12       NUMBER,
  DUPLI     VARCHAR2(1 BYTE),
  S1        NUMBER,
  S2        NUMBER,
  S3        NUMBER,
  S4        NUMBER,
  S5        NUMBER,
  S6        NUMBER,
  S7        NUMBER,
  S8        NUMBER,
  S9        NUMBER,
  S10       NUMBER,
  S11       NUMBER,
  S12       NUMBER,
  P1        NUMBER(5),
  P2        NUMBER(5),
  P3        NUMBER(5),
  P4        NUMBER(5),
  P5        NUMBER(5),
  P6        NUMBER(5),
  P7        NUMBER(5),
  P8        NUMBER(5),
  P9        NUMBER(5),
  P10       NUMBER(5),
  P11       NUMBER(5),
  P12       NUMBER(5),
  CP1       NUMBER,
  CP2       NUMBER,
  CP3       NUMBER,
  CP4       NUMBER,
  CP5       NUMBER,
  CP6       NUMBER,
  CP7       NUMBER,
  CP8       NUMBER,
  CP9       NUMBER,
  CP10      NUMBER,
  CP11      NUMBER,
  CP12      NUMBER,
  I1        NUMBER,
  I2        NUMBER,
  I3        NUMBER,
  I4        NUMBER,
  I5        NUMBER,
  I6        NUMBER,
  I7        NUMBER,
  I8        NUMBER,
  I9        NUMBER,
  I10       NUMBER,
  I11       NUMBER,
  I12       NUMBER,
  CI1       NUMBER,
  CI2       NUMBER,
  CI3       NUMBER,
  CI4       NUMBER,
  CI5       NUMBER,
  CI6       NUMBER,
  CI7       NUMBER,
  CI8       NUMBER,
  CI9       NUMBER,
  CI10      NUMBER,
  CI11      NUMBER,
  CI12      NUMBER,
  PROMOC    VARCHAR2(1 BYTE),
  DIV       NUMBER
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

--
-- ESTVENDEDOR  (Table) 
**BORRADA DE VISMAR
--
CREATE TABLE ESTVENDEDOR
(
  CODIGO  VARCHAR2(6 BYTE),
  NOMBRE  VARCHAR2(30 BYTE),
  VTA1    NUMBER,
  VTA2    NUMBER,
  VTA3    NUMBER,
  VTA4    NUMBER,
  VTA5    NUMBER,
  COS1    NUMBER,
  COS2    NUMBER,
  COS3    NUMBER,
  COS4    NUMBER,
  COS5    NUMBER,
  DESCTO  NUMBER
)
LOGGING 
NOCACHE
NOPARALLEL
NOMONITORING;

--
-- EST_COMAGENTE  (Table) 
--