-- generated by export_tables.php on 2025-12-02 16:02:03
-- source: ip.sysfar.com.br/gtsyscon_gtsys -> table: gtsys_cest_associacao_atual

create table gtsys_cest_associacao_atual
(
  `codigo` smallint(6) NOT NULL AUTO_INCREMENT,
  `codigo_ncm` int(11) NOT NULL,
  `cest_o` int(11) NOT NULL,
  `cest_r_p` int(11) NOT NULL,
  `cest_r_n` int(11) NOT NULL,
  `cest_r_nt` int(11) NOT NULL,
  `cest_g_p` int(11) NOT NULL,
  `cest_g_n` int(11) NOT NULL,
  `cest_g_nt` int(11) NOT NULL,
  `cest_s_p` int(11) NOT NULL,
  `cest_s_n` int(11) NOT NULL,
  `cest_s_nt` int(11) NOT NULL,
  `cest_o_p` int(11) NOT NULL,
  `cest_o_n` int(11) NOT NULL,
  `cest_o_nt` int(11) NOT NULL,
  PRIMARY KEY (`codigo`,`codigo_ncm`,`cest_o`,`cest_r_p`,`cest_r_n`,`cest_r_nt`,`cest_g_p`,`cest_g_n`,`cest_g_nt`,`cest_s_p`,`cest_s_n`,`cest_s_nt`,`cest_o_p`,`cest_o_n`,`cest_o_nt`),
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_10` FOREIGN KEY (`cest_s_n`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_11` FOREIGN KEY (`cest_s_nt`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_12` FOREIGN KEY (`cest_o_p`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_13` FOREIGN KEY (`cest_o_n`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_14` FOREIGN KEY (`cest_o_nt`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_2` FOREIGN KEY (`cest_o`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_3` FOREIGN KEY (`cest_r_p`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_4` FOREIGN KEY (`cest_r_n`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_5` FOREIGN KEY (`cest_r_nt`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_6` FOREIGN KEY (`cest_g_p`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_7` FOREIGN KEY (`cest_g_n`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_8` FOREIGN KEY (`cest_g_nt`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `gtsys_cest_associacao_atual_ibfk_9` FOREIGN KEY (`cest_s_p`) REFERENCES `gtsys_cest` (`codigo`) ON DELETE CASCADE ON UPDATE CASCADE
)ENGINE=InnoDB DEFAULT CHARSET=latin1;

create index codigo
    on gtsys_cest_associacao_atual (codigo);

create index codigo_ncm
    on gtsys_cest_associacao_atual (codigo_ncm);

create index gtsys_cest_associacao_ibfk_2
    on gtsys_cest_associacao_atual (cest_o);

create index gtsys_cest_associacao_ibfk_3
    on gtsys_cest_associacao_atual (cest_r_p);

create index gtsys_cest_associacao_ibfk_4
    on gtsys_cest_associacao_atual (cest_r_n);

create index gtsys_cest_associacao_ibfk_5
    on gtsys_cest_associacao_atual (cest_r_nt);

create index gtsys_cest_associacao_ibfk_6
    on gtsys_cest_associacao_atual (cest_g_p);

create index gtsys_cest_associacao_ibfk_7
    on gtsys_cest_associacao_atual (cest_g_n);

create index gtsys_cest_associacao_ibfk_8
    on gtsys_cest_associacao_atual (cest_g_nt);

create index gtsys_cest_associacao_ibfk_9
    on gtsys_cest_associacao_atual (cest_s_p);

create index gtsys_cest_associacao_ibfk_10
    on gtsys_cest_associacao_atual (cest_s_n);

create index gtsys_cest_associacao_ibfk_11
    on gtsys_cest_associacao_atual (cest_s_nt);

create index gtsys_cest_associacao_ibfk_12
    on gtsys_cest_associacao_atual (cest_o_p);

create index gtsys_cest_associacao_ibfk_13
    on gtsys_cest_associacao_atual (cest_o_n);

create index gtsys_cest_associacao_ibfk_14
    on gtsys_cest_associacao_atual (cest_o_nt);

