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

create table gtsys_ncm_backup
(
  `codigo` int(11) NOT NULL AUTO_INCREMENT,
  `ncm` char(10) NOT NULL,
  `descricao` text,
  `unidade` char(10) DEFAULT NULL,
  `codigo_piscofins` int(11) NOT NULL,
  `codigo_cstpis_saida` int(11) NOT NULL,
  `codigo_cstcofins_saida` int(11) NOT NULL,
  `codigo_cstpis_saida_sn` int(11) NOT NULL,
  `codigo_cstcofins_saida_sn` int(11) NOT NULL,
  `codigo_cstpis_entrada` int(11) NOT NULL,
  `codigo_cstcofins_entrada` int(11) NOT NULL,
  `codigo_cstpis_entrada_sn` int(11) NOT NULL,
  `codigo_cstcofins_entrada_sn` int(11) NOT NULL,
  `dispositivo_legal` text,
  `aliquota_pis_re` double(4,2) DEFAULT NULL,
  `aliquota_pis_pr` double(4,2) DEFAULT NULL,
  `aliquota_cofins_re` double(4,2) DEFAULT NULL,
  `aliquota_cofins_pr` double(4,2) DEFAULT NULL,
  `situacao` enum('ativo','inativo') DEFAULT 'ativo',
  PRIMARY KEY (`codigo`,`codigo_piscofins`,`codigo_cstpis_saida`,`codigo_cstcofins_saida`,`codigo_cstpis_saida_sn`,`codigo_cstcofins_saida_sn`,`codigo_cstpis_entrada`,`codigo_cstcofins_entrada`,`codigo_cstpis_entrada_sn`,`codigo_cstcofins_entrada_sn`),
  CONSTRAINT `gtsys_ncm_backup_ibfk_1` FOREIGN KEY (`codigo_cstcofins_saida`) REFERENCES `gtsys_cstcofins` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `gtsys_ncm_backup_ibfk_2` FOREIGN KEY (`codigo_cstcofins_saida_sn`) REFERENCES `gtsys_cstcofins` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `gtsys_ncm_backup_ibfk_3` FOREIGN KEY (`codigo_cstpis_saida`) REFERENCES `gtsys_cstpis` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `gtsys_ncm_backup_ibfk_4` FOREIGN KEY (`codigo_cstpis_saida_sn`) REFERENCES `gtsys_cstpis` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `gtsys_ncm_backup_ibfk_5` FOREIGN KEY (`codigo_piscofins`) REFERENCES `gtsys_piscofins` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `gtsys_ncm_backup_ibfk_6` FOREIGN KEY (`codigo_cstpis_entrada`) REFERENCES `gtsys_cstpis` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `gtsys_ncm_backup_ibfk_7` FOREIGN KEY (`codigo_cstcofins_entrada`) REFERENCES `gtsys_cstcofins` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `gtsys_ncm_backup_ibfk_8` FOREIGN KEY (`codigo_cstpis_entrada_sn`) REFERENCES `gtsys_cstpis` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `gtsys_ncm_backup_ibfk_9` FOREIGN KEY (`codigo_cstcofins_entrada_sn`) REFERENCES `gtsys_cstcofins` (`codigo`) ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE=InnoDB AUTO_INCREMENT=2825 DEFAULT CHARSET=latin1;

create index piscofins
    on gtsys_ncm_backup (codigo_piscofins);

create index cstpis_saida
    on gtsys_ncm_backup (codigo_cstpis_saida);

create index cstcofins_saida
    on gtsys_ncm_backup (codigo_cstcofins_saida);

create index cstpis_saida_sn
    on gtsys_ncm_backup (codigo_cstpis_saida_sn);

create index cstcofins_saida_sn
    on gtsys_ncm_backup (codigo_cstcofins_saida_sn);

create index codigo
    on gtsys_ncm_backup (codigo);

create index sgt_ncm_ibfk_6
    on gtsys_ncm_backup (codigo_cstpis_entrada);

create index sgt_ncm_ibfk_7
    on gtsys_ncm_backup (codigo_cstcofins_entrada);

create index sgt_ncm_ibfk_8
    on gtsys_ncm_backup (codigo_cstpis_entrada_sn);

create index sgt_ncm_ibfk_9
    on gtsys_ncm_backup (codigo_cstcofins_entrada_sn);

create index sgt_ncm_ibk_10
    on gtsys_ncm_backup (ncm);

