MySQL无法创建表[错误号:150]

时间:2022-02-24 21:10:23

Getting the above error on the following script:

在以下脚本上获得上述错误:

DROP TABLE IF EXISTS `incident`;

SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `incident` (
  `incident_id` int(11) NOT NULL auto_increment,
  `patient_id` int(11) default NULL,
  `history_id` int(11) default NULL,
  `incident_date` datetime default NULL,
  `incidentname_id` int(11) default NULL,
  `incident_type_id` int(11) default NULL,
  `pop_first_symptom` int(11) default NULL,
  `first_symptom_date` datetime default NULL,
  `similar_symptom_date` datetime default NULL,
  `first_consultation_date` datetime default NULL,
  `accident` int(1) default NULL,
  `accident_date` datetime default NULL,
  `pop_accident_state` int(11) default NULL,
  `pop_condition_related_to` int(11) default NULL,
  `flag_prothesis` char(1) collate utf8_unicode_ci NOT NULL default '0',
  `flag_initial_placement` char(1) collate utf8_unicode_ci NOT NULL default '0',
  `flag_orthodontics` char(1) collate utf8_unicode_ci NOT NULL default '0',
  `flag_occupational_illness` char(1) collate utf8_unicode_ci NOT NULL default '0',
  `box19` varchar(80) collate utf8_unicode_ci NOT NULL default '',
  `color` varchar(8) collate utf8_unicode_ci NOT NULL default 'ffffff00',
  `referrals_id` int(11) default NULL,
  `referral_date` datetime default NULL,
  `facility_id` int(11) default NULL,
  `attorney_id` int(11) default NULL,
  `attorney_notes` text collate utf8_unicode_ci,
  `attorney_report_sent` date default NULL,
  `attorney_deposition_date` date default NULL,
  `attorney_trial_date` date default NULL,
  `attorney_notice_filing` char(1) collate utf8_unicode_ci default NULL,
  `attorney_final_settlement` date default NULL,
  `effective_date` datetime default NULL,
  `termination_date` datetime default NULL,
  `date` datetime default NULL,
  `pop_branch` int(11) default NULL,
  `pop_status` int(1) default NULL,
  `pop_eligibility` int(1) default NULL,
  `partial_begin_date` datetime default NULL,
  `partial_end_date` datetime default NULL,
  `last_work_date` datetime default NULL,
  `partial_return_to_work_date` datetime default NULL,
  `total_begin_date` datetime default NULL,
  `total_end_date` datetime default NULL,
  `last_xray_date` datetime default NULL,
  `last_seen_date` date default NULL,
  `assumed_date` datetime default NULL,
  `relinquished_date` datetime default NULL,
  `radiographs` varchar(30) collate utf8_unicode_ci NOT NULL default '',
  `oral_images` varchar(30) collate utf8_unicode_ci NOT NULL default '',
  `models` varchar(30) collate utf8_unicode_ci NOT NULL default '',
  `date_appliance_placed` date default NULL,
  `date_prior_placement` date default NULL,
  `paymentSourceCode` varchar(10) collate utf8_unicode_ci NOT NULL default '',
  `locatorCode` varchar(10) collate utf8_unicode_ci NOT NULL default '',
  `SAExceptionCode` varchar(10) collate utf8_unicode_ci NOT NULL default '',
  `flag_expanded` int(1) default NULL,
  `flag_archived` int(1) default NULL,
  `cda_reason_code` int(11) default NULL,
  `is_extraction` int(11) default '0',
  `extraction_tooth` varchar(10) collate utf8_unicode_ci default NULL,
  `initial_placement_date` date default NULL,
  `initial_placement_location` int(11) default '0',
  `prosthesis_material` int(11) default '0',
  PRIMARY KEY  (`incident_id`),
  KEY `patient_id_key` (`patient_id`),
  CONSTRAINT `incident_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patient` (`patient_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9854 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;

Here is the patient table giving me the same error:

这是患者表给我同样的错误:

    DROP TABLE IF EXISTS `patient`;
SET @saved_cs_client     = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `patient` (
  `patient_id` int(11) NOT NULL auto_increment,
  `history_id` int(11) default NULL,
  `person_id` int(11) default NULL,
  `account_id` int(11) default NULL,
  `display_id` varchar(10) collate utf8_unicode_ci default NULL,
  `chart_num` varchar(10) collate utf8_unicode_ci default NULL,
  `bridge_num` varchar(10) collate utf8_unicode_ci default NULL,
  `provider_id` int(11) default NULL,
  `office_id` int(11) default NULL,
  `feeschedule_id` int(11) default NULL,
  `pop_marital_status` int(11) default NULL,
  `pop_employment` int(11) default NULL,
  `new_patient_date` date default NULL,
  `primary_ins_id` int(11) default NULL,
  `primary_ins_type` char(1) collate utf8_unicode_ci default NULL,
  `insured_id_number` varchar(30) collate utf8_unicode_ci default NULL,
  `flag_special_insurance` char(1) collate utf8_unicode_ci default '0',
  `flag_family_planning` char(1) collate utf8_unicode_ci default '0',
  `flag_epstd` char(1) collate utf8_unicode_ci default '0',
  `pop_relation_to_primary` int(11) default NULL,
  `pop_relation_to_secondary` int(11) default NULL,
  `pop_hipaa_release` int(11) default NULL,
  `hipaa_release_date` date default NULL,
  `patientNotes` text collate utf8_unicode_ci,
  `autoremind_notification_type_id` int(11) NOT NULL default '0',
  `ethnicity_id` int(11) default NULL,
  `patient_status` int(1) NOT NULL default '0',
  `created_by_module` char(1) collate utf8_unicode_ci NOT NULL default 'P',
  `pop_patient_exception_code` int(11) default '0',
  `pop_native_language` int(11) default '0',
  `school_name` varchar(30) collate utf8_unicode_ci default NULL,
  `graduation_date` date default NULL,
  `hygienist_id` int(11) default NULL,
  `school_address_id` int(11) default NULL,
  `language_id` int(11) default NULL,
  PRIMARY KEY  (`patient_id`),
  KEY `account_id_key` (`account_id`),
  KEY `person_id_key` (`person_id`),
  KEY `patient_status_index` (`patient_status`),
  KEY `person_id_index` (`person_id`),
  KEY `account_id_index` (`account_id`),
  CONSTRAINT `patient_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`),
  CONSTRAINT `patient_ibfk_2` FOREIGN KEY (`person_id`) REFERENCES `person` (`person_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9855 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
SET character_set_client = @saved_cs_client;

1 个解决方案

#1


0  

I assume that your foreign key patient_id is not NULL. It must match to your referenced data type.

我假设你的外键patient_id不是NULL。它必须与您引用的数据类型匹配。

`patient_id` int(11) default NULL

#1


0  

I assume that your foreign key patient_id is not NULL. It must match to your referenced data type.

我假设你的外键patient_id不是NULL。它必须与您引用的数据类型匹配。

`patient_id` int(11) default NULL