任何人都可以解释为什么Mysql给我错误1280(“fk_chart_aid_aid错误索引”)错误当我尝试创建“CHART OF ACCOUNTS”表时。我在这里完全困惑。我如何解决这个问题,以便我可以创建表格? “ACCOUNT”表已经存在于数据库中并且有数据。为什么Mysql给我错误1280“错误索引”
感谢您的帮助。
MySQL服务器版本:54年5月1日
图表会计:
DROP TABLE IF EXISTS `rst`.`acctg_chart_of_accounts` ;
CREATE TABLE IF NOT EXISTS `rst`.`acctg_chart_of_accounts` (
`acctg_chart_of_accounts_id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`account_id` INT UNSIGNED NOT NULL ,
`account_nbr` VARCHAR(45) NULL ,
`description` VARCHAR(45) NULL ,
`account_type` INT UNSIGNED NULL ,
`commissionable` TINYINT UNSIGNED NULL ,
`hidden` TINYINT UNSIGNED NULL ,
`deduct_balance_from_owner_check` TINYINT UNSIGNED NULL ,
PRIMARY KEY (`acctg_chart_of_accounts_id`) ,
CONSTRAINT `fk_chart_aid_aid`
FOREIGN KEY (`account_id`)
REFERENCES `rst`.`account` (`account_id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
CREATE INDEX `fk_chart_aid_aid` ON `rst`.`acctg_chart_of_accounts` (`account_id` ASC) ;
账表被参考:
CREATE TABLE IF NOT EXISTS `account` (
`account_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`account_status_id` int(10) unsigned NOT NULL,
`company_name` varchar(155) DEFAULT NULL,
`address1` varchar(155) DEFAULT NULL,
`address2` varchar(155) DEFAULT NULL,
`city` varchar(155) DEFAULT NULL,
`state` varchar(155) DEFAULT NULL,
`zip` varchar(45) DEFAULT NULL,
`country` varchar(255) DEFAULT NULL,
`work_phone` varchar(45) DEFAULT NULL,
`mobile_phone` varchar(45) DEFAULT NULL,
`time_zone` varchar(45) DEFAULT NULL,
`subdomain` varchar(155) DEFAULT NULL,
`cname_URL` varchar(255) DEFAULT NULL,
`promotion_code` varchar(45) DEFAULT NULL,
`can_we_contact_you` tinyint(4) DEFAULT NULL COMMENT '0=false, 1=true',
`units_managed_nbr` varchar(10) DEFAULT NULL,
`a_hear_about_us_list_id` tinyint(3) unsigned DEFAULT NULL COMMENT 'populated from dropdown list.',
`receive_special_offers` tinyint(4) DEFAULT NULL,
`receive_announcements` tinyint(4) DEFAULT NULL,
`receive_newsletter` tinyint(4) DEFAULT NULL,
`create_ts` timestamp NULL DEFAULT NULL,
`expires` timestamp NULL DEFAULT NULL,
`storage_capacity` varchar(255) DEFAULT NULL COMMENT '1073741824 = 1GB',
`logo` varchar(455) DEFAULT NULL,
`max_active_connections` int(11) DEFAULT '3',
`_product_id` int(11) DEFAULT NULL,
`report_footer` varchar(455) DEFAULT NULL,
`welcome_dialog` tinyint(4) DEFAULT '1',
`ARB_subscription_id` int(11) DEFAULT NULL,
`trashbin` tinyint(4) NOT NULL DEFAULT '1',
PRIMARY KEY (`account_id`),
KEY `fk_account_account_status_id` (`account_status_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=58 ;
“创建表”的作品,所以后来的错误。我使用“MySql Workbench”来生成表格的代码...我只是假设代码是正确的...我会尝试更改“索引名称”,看看会发生什么。 – Ronedog
好的,改变索引名称是不同的固定它。 Mysql工作台强制名称相同,任何想法为什么工作台都这样做? – Ronedog
@Ronedog Nope。我只有有限的Workbench经验。我通常手动编码所有内容并在命令行上工作。很高兴它整理出来。 –