-- Create table
create table ADAM.FCO_INTEGRADA_DET
(
  COMPANIA                CHAR(4) not null,
  ANIO                    NUMBER not null,
  MES                     NUMBER not null,
  SUCURSAL                VARCHAR2(10) not null,
  TIPO_PLANILLA           CHAR(1) not null,
  TRABAJADOR              CHAR(10) not null,
  CONSECUTIVO             NUMBER(1) not null,
  SECUENCIA               CHAR(5) not null,
  TIPO_DOCUMENTO          CHAR(2) not null,
  NRO_ID                  VARCHAR2(16) not null,
  DIGITO_CHEQUEO          CHAR(1) not null,
  TIPO_COTIZANTE          NUMBER not null,
  SUBTIPO_COTIZANTE       NUMBER not null,
  EXTRANJERO_NO_PENSION   CHAR(1) not null,
  RESIDENTE_EN_EXTERIOR   CHAR(1) not null,
  DEPARTAMENTO            CHAR(2) not null,
  MUNICIPIO               CHAR(3) not null,
  PRIMER_APELLIDO         VARCHAR2(20) not null,
  SEGUNDO_APELLIDO        VARCHAR2(30) not null,
  PRIMER_NOMBRE           VARCHAR2(20) not null,
  SEGUNDO_NOMBRE          VARCHAR2(30) not null,
  NOV_ING                 CHAR(1) not null,
  NOV_RET                 CHAR(1) not null,
  NOV_TDE                 CHAR(1) not null,
  NOV_TAE                 CHAR(1) not null,
  NOV_TDP                 CHAR(1) not null,
  NOV_TAP                 CHAR(1) not null,
  NOV_VSP                 CHAR(1) not null,
  NOV_VTE                 CHAR(1) not null,
  NOV_VST                 CHAR(1) not null,
  NOV_SLN                 CHAR(1) not null,
  NOV_IGE                 CHAR(1) not null,
  NOV_LMA                 CHAR(1) not null,
  NOV_VAC                 CHAR(1) not null,
  NOV_AVP                 CHAR(1) not null,
  NOV_VCT                 CHAR(1) not null,
  NOV_IRP                 CHAR(2) not null,
  COD_AFP                 CHAR(10) not null,
  COD_AFP_TRAS            CHAR(10) not null,
  COD_EPS                 CHAR(10) not null,
  COD_EPS_TRAS            CHAR(10) not null,
  COD_CCF                 CHAR(10) not null,
  DIAS_AFP                NUMBER not null,
  DIAS_EPS                NUMBER not null,
  DIAS_ARP                NUMBER not null,
  DIAS_CCF                NUMBER not null,
  SALARIO                 NUMBER(9) not null,
  INTEGRAL                CHAR(1) not null,
  IBC_AFP                 NUMBER(9) not null,
  IBC_EPS                 NUMBER(9) not null,
  IBC_ARP                 NUMBER(9) not null,
  IBC_CCF                 NUMBER(9) not null,
  TARIFA_AFP              NUMBER(6,5) not null,
  APORTE_AFP              NUMBER(9) not null,
  VOLUNTARIO_AFP          NUMBER(9) not null,
  VOLUNTARIO_AFP_CIA      NUMBER(9) not null,
  APORTE_TOTAL_AFP        NUMBER,
  APORTE_FSP              NUMBER(9) not null,
  APORTE_FSP_SUBSISTENCIA NUMBER(9) not null,
  VALOR_NO_RETENIDO       NUMBER(9) not null,
  TARIFA_EPS              NUMBER(6,5) not null,
  APORTE_EPS              NUMBER(9) not null,
  UPC_ADICIONAL           NUMBER(9) not null,
  NRO_AUT_IGE             VARCHAR2(15) not null,
  VLR_AUT_IGE             NUMBER(9) not null,
  NRO_AUT_LMA             VARCHAR2(15) not null,
  VLR_AUT_LMA             NUMBER(9) not null,
  TARIFA_ARP              NUMBER(9,8) not null,
  CENTRO_TRABAJO          NUMBER(9) not null,
  APORTE_ARP              NUMBER(9) not null,
  TARIFA_CCF              NUMBER(6,5) not null,
  APORTE_CCF              NUMBER(9) not null,
  TARIFA_SENA             NUMBER(6,5) not null,
  APORTE_SENA             NUMBER(9) not null,
  TARIFA_ICBF             NUMBER(6,5) not null,
  APORTE_ICBF             NUMBER(9) not null,
  TARIFA_ESAP             NUMBER(6,5) not null,
  APORTE_ESAP             NUMBER(9) not null,
  TARIFA_MEDU             NUMBER(6,5) not null,
  APORTE_MEDU             NUMBER(9) not null,
  ORIGEN                  NUMBER not null,
  ELIMINADA               NUMBER(1) default 0 not null
)
tablespace TS_ADAMDATOS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
-- Create/Recreate primary, unique and foreign key constraints 
alter table ADAM.FCO_INTEGRADA_DET
  add constraint PK_FCO_INTEGRADA_DET primary key (COMPANIA, ANIO, MES, SUCURSAL, TIPO_PLANILLA, TRABAJADOR, CONSECUTIVO)
  using index 
  tablespace TS_ADAMINDICES
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
-- Create/Recreate check constraints 
alter table ADAM.FCO_INTEGRADA_DET
  add constraint CHK1
  check (origen in (1, 2, 3));


