-2
我有一個表:找出是否存在索引的MySQL
CREATE TABLE IF NOT EXISTS `agents` (
`idx` int(11) NOT NULL AUTO_INCREMENT,
`newConfig` tinyint(1) NOT NULL DEFAULT '0',
`agent_id` char(20) NOT NULL,
`time` int(11) NOT NULL,
`status` varchar(15) NOT NULL,
`agent_ip` char(15) NOT NULL,
`FilterExpression` varchar(1024) NOT NULL,
`agent_alias` char(128) NOT NULL,
`agent_type` char(128) NOT NULL,
`ATMSIP` varchar(15) NOT NULL,
`ATMSPort` varchar(5) NOT NULL,
`MaxHeadersLength` varchar(10) NOT NULL,
`MaxGetParamsLength` varchar(10) NOT NULL,
`MaxPostLength` varchar(10) NOT NULL,
`StatusInterval` int(11) NOT NULL,
`CookieExpireTime` int(11) NOT NULL,
`ConcurrentSessions` varchar(10) NOT NULL,
`MessagesQueueSize` varchar(10) NOT NULL,
`owner_user` char(20) NOT NULL,
`owner_group` char(20) NOT NULL,
`msg_id` bigint(20) NOT NULL,
`NetworkInterface` char(64) NOT NULL,
`fingerprint_headers` varchar(4096) NOT NULL,
PRIMARY KEY (`idx`),
UNIQUE KEY `agent_id` (`agent_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
現在我想驗證指數AGENT_ID加入(如果該表已經存在,因此沒有創建)做:
if not exists (SELECT INDEX_NAME FROM INFORMATION_SCHEMA.STATISTICS WHERE
`TABLE_SCHEMA` = 'Telepath-NewSchema' AND
`TABLE_NAME` = `agents` AND `INDEX_NAME` = `agent_id`)
then
ALTER IGNORE TABLE `agents` ADD UNIQUE `agent_id` (`agent_id`);
end if;
但是當我運行該腳本,我得到: 未知列「代理」在「where子句」
爲什麼它認爲是代理一列?
感謝