你能幫我解決這個問題嗎? 其實我試圖TRUNCATE
一些TABLES
在MySql中的數據庫,但是當我嘗試這樣做時,出現錯誤。MySql SET FOREIGN_KEY_CHECK不起作用
請在計,我已經設置好的了FOREIGN_KEY_CHECK
爲0,就像說,在line 2
和line 9
所以返回到1,爲什麼呢?以及如何解決?
更新1
添加表結構
--
-- Table structure for table `metadata`
--
CREATE TABLE IF NOT EXISTS `metadata` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user` int(11) NOT NULL,
`date` date NOT NULL,
`time` time NOT NULL,
`ip` varchar(15) NOT NULL,
PRIMARY KEY (`id`),
KEY `user` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=54 ;
-- --------------------------------------------------------
--
-- Table structure for table `patients`
--
CREATE TABLE IF NOT EXISTS `patients` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`nss` bigint(11) DEFAULT NULL,
`name_1st` varchar(50) NOT NULL,
`name_2nd` varchar(30) DEFAULT NULL,
`last_name_1st` varchar(50) NOT NULL,
`last_name_2nd` varchar(30) DEFAULT NULL,
`clinic` int(11) DEFAULT NULL,
`attached` text,
`valid` tinyint(1) DEFAULT NULL,
`status` tinyint(2) NOT NULL,
`metadata` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `status` (`status`),
KEY `clinic` (`clinic`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ;
-- --------------------------------------------------------
--
-- Table structure for table `queue`
--
CREATE TABLE IF NOT EXISTS `queue` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`consecutive` int(11) NOT NULL,
`creat_day` date NOT NULL,
`patient` bigint(20) DEFAULT NULL,
`status` tinyint(2) DEFAULT NULL,
`metadata` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `consecutive` (`consecutive`,`creat_day`),
KEY `status` (`status`),
KEY `metadata` (`metadata`),
KEY `patient_ident` (`patient`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ;
-- --------------------------------------------------------
--
-- Table structure for table `triage_regs`
--
CREATE TABLE IF NOT EXISTS `triage_regs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`queue` bigint(20) NOT NULL,
`patient` bigint(20) NOT NULL,
`cod_color` int(11) NOT NULL,
`medicines` text NOT NULL,
`time_start_triage` time NOT NULL,
`time_end_triage` time NOT NULL,
`tens_arterial` varchar(7) NOT NULL,
`frec_card` int(3) NOT NULL,
`frec_resp` int(3) NOT NULL,
`temp` int(3) NOT NULL,
`gluc` int(3) NOT NULL,
`esc_glasgown` int(3) NOT NULL,
`atention` varchar(500) NOT NULL DEFAULT 'n/a',
`questions` longtext,
`exp_fis` longtext,
`aux_diag` longtext,
`pron` longtext,
`trat` longtext,
`diag` longtext,
`status` tinyint(2) NOT NULL,
`metadata` bigint(20) DEFAULT NULL,
`metadata2` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `patient` (`patient`),
KEY `status` (`status`),
KEY `metadata2` (`metadata2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
請出示表結構 –
@MuhammadMuazzam更新 –
http://stackoverflow.com/questions/5452760/truncate-foreign-key-constrained-table/8074510#8074510 –